-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput-date.vue
More file actions
380 lines (358 loc) · 8.81 KB
/
input-date.vue
File metadata and controls
380 lines (358 loc) · 8.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<!-- eslint-disable vue/multi-word-component-names -->
<script setup>
import { parseDate, CalendarDate } from '@internationalized/date'
const data = { date2: new CalendarDate(2022, 2, 3) }
const inputDateSchema = [
{
$formkit: 'nuxtUIInputDate',
id: 'inputdate-basic',
name: 'date1',
label: 'Basic Date',
validation: 'required',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date2',
label: 'With Default Value',
defaultValue: new CalendarDate(2022, 3, 3),
},
{
$formkit: 'nuxtUIInputDate',
name: 'date3',
label: 'With Placeholder',
placeholder: new CalendarDate(2022, 7, 7),
},
{
$formkit: 'nuxtUIInputDate',
name: 'date4',
label: 'Date Range',
range: true,
},
{
$formkit: 'nuxtUIInputDate',
name: 'date5',
label: 'Date Range with Custom Separator',
range: true,
separatorIcon: 'i-heroicons-arrow-right',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date6',
label: 'Date with Time (hour granularity)',
granularity: 'hour',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date7',
label: 'Date with Time (minute granularity)',
granularity: 'minute',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date8',
label: 'Date with Time (second granularity)',
granularity: 'second',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date9',
label: '24 Hour Cycle',
granularity: 'minute',
hourCycle: 24,
},
{
$formkit: 'nuxtUIInputDate',
name: 'date10',
label: '12 Hour Cycle',
granularity: 'minute',
hourCycle: 12,
},
{
$formkit: 'nuxtUIInputDate',
name: 'date11',
label: 'Hide Timezone',
granularity: 'minute',
hideTimeZone: true,
},
{
$formkit: 'nuxtUIInputDate',
name: 'date12',
label: 'With Min/Max Values',
minValue: parseDate('2026-01-01'),
maxValue: parseDate('2026-12-31'),
},
{
$formkit: 'nuxtUIInputDate',
name: 'date13',
label: 'With Autofocus',
autofocus: true,
},
{
$formkit: 'nuxtUIInputDate',
name: 'date14',
label: 'With Autofocus Delay (1000ms)',
autofocus: true,
autofocusDelay: 1000,
},
{
$formkit: 'nuxtUIInputDate',
name: 'date15',
label: 'With Leading Icon',
leadingIcon: 'i-heroicons-calendar',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date16',
label: 'With Trailing Icon',
trailingIcon: 'i-heroicons-clock',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date17',
label: 'With Icon',
icon: 'i-heroicons-calendar-days',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date18',
label: 'With Avatar',
avatar: { src: 'https://i.pravatar.cc/150?img=2', alt: 'User Avatar' },
},
{
$formkit: 'nuxtUIInputDate',
name: 'date19',
label: 'Loading State',
loading: true,
},
{
$formkit: 'nuxtUIInputDate',
name: 'date20',
label: 'Custom Loading Icon',
loading: true,
loadingIcon: 'i-heroicons-arrow-path',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date21',
label: 'Highlighted',
highlight: true,
},
{
$formkit: 'nuxtUIInputDate',
name: 'date22',
label: 'Extra Small Size',
size: 'xs',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date23',
label: 'Small Size',
size: 'sm',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date24',
label: 'Medium Size (Default)',
size: 'md',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date25',
label: 'Large Size',
size: 'lg',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date26',
label: 'Extra Large Size',
size: 'xl',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date27',
label: 'Primary Color',
color: 'primary',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date28',
label: 'Success Color',
color: 'success',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date29',
label: 'Error Color',
color: 'error',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date30',
label: 'Variant None',
variant: 'none',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date31',
label: 'Variant Ghost',
variant: 'ghost',
},
{
$formkit: 'nuxtUIInputDate',
name: 'date32',
label: 'Disabled',
disabled: true,
defaultValue: new CalendarDate(2022, 3, 3),
},
]
</script>
<template>
<div>
<UContainer>
<div class="mb-8">
<h1 class="text-4xl font-bold mb-4">
InputDate Component
</h1>
<p class="text-lg text-muted-foreground mb-2">
The InputDate component integrates FormKit with Nuxt UI's UInputDate component, providing a rich date and time picker experience.
</p>
<p class="text-muted-foreground">
Explore various date configurations, ranges, time granularity, autofocus, icons, avatars, highlight, styling options, and states below.
</p>
</div>
<USeparator class="my-8" />
<div class="space-y-12">
<section>
<h2 class="text-2xl font-semibold mb-4">
Basic Usage
</h2>
<p class="text-muted-foreground mb-6">
Simple date picker with validation, default values, and placeholder.
</p>
<FUDataEdit
:data="data"
:schema="inputDateSchema.slice(0, 3)"
debug-data
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Date Ranges
</h2>
<p class="text-muted-foreground mb-6">
Select date ranges with customizable separator icons.
</p>
<FUDataEdit
:data="{}"
:schema="inputDateSchema.slice(3, 5)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Time Granularity
</h2>
<p class="text-muted-foreground mb-6">
Control date/time precision with granularity levels: hour, minute, or second.
</p>
<FUDataEdit
:data="{}"
:schema="inputDateSchema.slice(5, 8)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Time Configuration
</h2>
<p class="text-muted-foreground mb-6">
Configure hour cycle (12/24 hour) and timezone visibility.
</p>
<FUDataEdit
:data="{}"
:schema="inputDateSchema.slice(8, 11)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Validation Constraints
</h2>
<p class="text-muted-foreground mb-6">
Set minimum and maximum date values to constrain selection.
</p>
<FUDataEdit
:data="{}"
:schema="inputDateSchema.slice(11, 12)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Autofocus
</h2>
<p class="text-muted-foreground mb-6">
Control focus behavior with autofocus and autofocus delay options.
</p>
<FUDataEdit
:data="{}"
:schema="inputDateSchema.slice(12, 14)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Icons & Slots
</h2>
<p class="text-muted-foreground mb-6">
Add leading/trailing icons, avatars, and loading indicators.
</p>
<FUDataEdit
:data="{}"
:schema="inputDateSchema.slice(14, 21)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Sizes
</h2>
<p class="text-muted-foreground mb-6">
Available sizes: xs, sm, md (default), lg, and xl.
</p>
<FUDataEdit
:data="{}"
:schema="inputDateSchema.slice(21, 26)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
Colors & Variants
</h2>
<p class="text-muted-foreground mb-6">
Customize colors and variants to match your design.
</p>
<FUDataEdit
:data="{}"
:schema="inputDateSchema.slice(26, 31)"
/>
</section>
<USeparator />
<section>
<h2 class="text-2xl font-semibold mb-4">
States
</h2>
<p class="text-muted-foreground mb-6">
Disabled state.
</p>
<FUDataEdit
:data="{}"
:schema="inputDateSchema.slice(31, 32)"
/>
</section>
</div>
</UContainer>
</div>
</template>