-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(WheelPicker): add WheelPicker and WheelPickerGroup components #6866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
husamMousa
wants to merge
6
commits into
nuxt:v4
Choose a base branch
from
husamMousa:feat/wheel-picker
base: v4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,251
β3
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
885ff97
feat(WheelPicker): add WheelPicker and WheelPickerGroup components
husamMousa ed6a346
Merge branch 'v4' into feat/wheel-picker
husamMousa c886f97
Merge branch 'v4' into feat/wheel-picker
husamMousa 72cd8c6
docs(WheelPicker): simplify custom slot example to avoid type casts
husamMousa 47d25e3
fix(WheelPicker): use nullish fallback for disabled form-field ref
husamMousa cc1eb18
Merge branch 'v4' into feat/wheel-picker
husamMousa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
docs/app/components/content/examples/wheel-picker/WheelPickerCountriesExample.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <script setup lang="ts"> | ||
| import type { WheelPickerItem } from '@nuxt/ui' | ||
|
|
||
| const items = ref([ | ||
| { label: 'France', value: 'fr', icon: 'i-circle-flags-fr' }, | ||
| { label: 'Germany', value: 'de', icon: 'i-circle-flags-de' }, | ||
| { label: 'Italy', value: 'it', icon: 'i-circle-flags-it' }, | ||
| { label: 'Japan', value: 'jp', icon: 'i-circle-flags-jp' }, | ||
| { label: 'Spain', value: 'es', icon: 'i-circle-flags-es' }, | ||
| { label: 'United Kingdom', value: 'gb', icon: 'i-circle-flags-gb' }, | ||
| { label: 'United States', value: 'us', icon: 'i-circle-flags-us' } | ||
| ] satisfies WheelPickerItem[]) | ||
|
|
||
| const value = ref('jp') | ||
| </script> | ||
|
|
||
| <template> | ||
| <UWheelPicker v-model="value" :items="items" class="w-56" aria-label="Country" /> | ||
| </template> |
29 changes: 29 additions & 0 deletions
29
docs/app/components/content/examples/wheel-picker/WheelPickerDateExample.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <script setup lang="ts"> | ||
| const months = [ | ||
| 'January', 'February', 'March', 'April', 'May', 'June', | ||
| 'July', 'August', 'September', 'October', 'November', 'December' | ||
| ] | ||
|
|
||
| const days = Array.from({ length: 31 }, (_, i) => i + 1) | ||
| const years = Array.from({ length: 60 }, (_, i) => 1980 + i) | ||
|
|
||
| const month = ref('June') | ||
| const day = ref(15) | ||
| const year = ref(2000) | ||
|
|
||
| const date = computed(() => `${month.value} ${day.value}, ${year.value}`) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="flex flex-col items-center gap-4"> | ||
| <UWheelPickerGroup> | ||
| <UWheelPicker v-model="month" :items="months" class="w-32" aria-label="Month" /> | ||
| <UWheelPicker v-model="day" :items="days" class="w-16" aria-label="Day" loop /> | ||
| <UWheelPicker v-model="year" :items="years" class="w-20" aria-label="Year" /> | ||
| </UWheelPickerGroup> | ||
|
|
||
| <p class="text-sm text-muted"> | ||
| {{ date }} | ||
| </p> | ||
| </div> | ||
| </template> | ||
30 changes: 30 additions & 0 deletions
30
docs/app/components/content/examples/wheel-picker/WheelPickerFormExample.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <script setup lang="ts"> | ||
| import * as z from 'zod' | ||
| import type { FormSubmitEvent } from '@nuxt/ui' | ||
|
|
||
| const schema = z.object({ | ||
| size: z.enum(['S', 'M', 'L', 'XL'], { message: 'Select a valid size' }) | ||
| }) | ||
|
|
||
| type Schema = z.output<typeof schema> | ||
|
|
||
| const state = reactive<Partial<Schema>>({ | ||
| size: undefined | ||
| }) | ||
|
|
||
| const toast = useToast() | ||
|
|
||
| function onSubmit(event: FormSubmitEvent<Schema>) { | ||
| toast.add({ title: 'Success', description: `Size: ${event.data.size}`, color: 'success' }) | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <UForm :schema="schema" :state="state" class="flex flex-col items-center gap-4" @submit="onSubmit"> | ||
| <UFormField name="size" label="Size"> | ||
| <UWheelPicker v-model="state.size" :items="['S', 'M', 'L', 'XL']" class="w-24" /> | ||
| </UFormField> | ||
|
|
||
| <UButton type="submit" label="Submit" /> | ||
| </UForm> | ||
| </template> |
24 changes: 24 additions & 0 deletions
24
docs/app/components/content/examples/wheel-picker/WheelPickerSlotExample.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <script setup lang="ts"> | ||
| import type { WheelPickerItem } from '@nuxt/ui' | ||
|
|
||
| const items = ref([ | ||
| { label: 'Free', value: 'free', price: '$0', icon: 'i-lucide-sprout' }, | ||
| { label: 'Starter', value: 'starter', price: '$9', icon: 'i-lucide-rocket' }, | ||
| { label: 'Pro', value: 'pro', price: '$29', icon: 'i-lucide-crown' }, | ||
| { label: 'Enterprise', value: 'enterprise', price: '$99', icon: 'i-lucide-building-2' } | ||
| ] satisfies WheelPickerItem[]) | ||
|
|
||
| const value = ref('pro') | ||
|
|
||
| const prices = computed(() => Object.fromEntries(items.value.map(item => [item.value, item.price]))) | ||
| </script> | ||
|
|
||
| <template> | ||
| <UWheelPicker v-model="value" :items="items" :item-height="44" class="w-64" aria-label="Plan"> | ||
| <template #item="{ item, active }"> | ||
| <UIcon v-if="item.icon" :name="item.icon" class="size-5 shrink-0" /> | ||
| <span class="flex-1 text-start truncate">{{ item.label }}</span> | ||
| <span class="text-sm" :class="active ? 'text-primary' : 'text-dimmed'">{{ prices[String(item.value)] }}</span> | ||
| </template> | ||
| </UWheelPicker> | ||
| </template> |
25 changes: 25 additions & 0 deletions
25
docs/app/components/content/examples/wheel-picker/WheelPickerTimeExample.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <script setup lang="ts"> | ||
| const hours = Array.from({ length: 12 }, (_, i) => String(i + 1).padStart(2, '0')) | ||
| const minutes = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, '0')) | ||
| const periods = ['AM', 'PM'] | ||
|
|
||
| const hour = ref('09') | ||
| const minute = ref('30') | ||
| const period = ref('AM') | ||
|
|
||
| const time = computed(() => `${hour.value}:${minute.value} ${period.value}`) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="flex flex-col items-center gap-4"> | ||
| <UWheelPickerGroup color="primary"> | ||
| <UWheelPicker v-model="hour" :items="hours" class="w-16" aria-label="Hour" loop /> | ||
| <UWheelPicker v-model="minute" :items="minutes" class="w-16" aria-label="Minute" loop /> | ||
| <UWheelPicker v-model="period" :items="periods" class="w-16" aria-label="Period" /> | ||
| </UWheelPickerGroup> | ||
|
|
||
| <p class="text-sm text-muted"> | ||
| {{ time }} | ||
| </p> | ||
| </div> | ||
| </template> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π― Functional Correctness | π‘ Minor | β‘ Quick win
Prevent invalid calendar dates.
Both examples always provide days 1 through 31. Users can select dates such as February 31. Derive the day items from the selected month and year. Clamp or reset
daywhen the new month has fewer days.docs/app/components/content/examples/wheel-picker/WheelPickerDateExample.vue#L7-L14: compute the day list frommonthandyear, then updatedaywhen its value exceeds the new maximum.playgrounds/nuxt/app/pages/components/wheel-picker.vue#L22-L27: computemonthDaysfrommonthandyear, then updatedaywhen its value exceeds the new maximum.π Affects 2 files
docs/app/components/content/examples/wheel-picker/WheelPickerDateExample.vue#L7-L14(this comment)playgrounds/nuxt/app/pages/components/wheel-picker.vue#L22-L27π€ Prompt for AI Agents