Merge remote-tracking branch 'origin/dev' into feat/tags-input

This commit is contained in:
zernonia 2024-02-15 15:02:46 +01:00
commit b216432f28
49 changed files with 645 additions and 66 deletions

View File

@ -2,6 +2,7 @@
import PageHeader from '../components/PageHeader.vue' import PageHeader from '../components/PageHeader.vue'
import PageHeaderHeading from '../components/PageHeaderHeading.vue' import PageHeaderHeading from '../components/PageHeaderHeading.vue'
import PageHeaderDescription from '../components/PageHeaderDescription.vue' import PageHeaderDescription from '../components/PageHeaderDescription.vue'
import PageAction from '../components/PageAction.vue'
import ExamplesNav from '../components/ExamplesNav.vue' import ExamplesNav from '../components/ExamplesNav.vue'
import { announcementConfig } from '../config/site' import { announcementConfig } from '../config/site'
import GitHubIcon from '~icons/radix-icons/github-logo' import GitHubIcon from '~icons/radix-icons/github-logo'
@ -31,7 +32,7 @@ import DashboardExample from '@/examples/dashboard/Example.vue'
apps. Accessible. Customizable. Open Source. apps. Accessible. Customizable. Open Source.
</PageHeaderDescription> </PageHeaderDescription>
<section class="flex w-full items-center space-x-4 pb-8 pt-4 md:pb-10"> <PageAction>
<a <a
href="/docs/introduction" href="/docs/introduction"
:class="cn(buttonVariants(), 'rounded-[6px]')" :class="cn(buttonVariants(), 'rounded-[6px]')"
@ -49,7 +50,7 @@ import DashboardExample from '@/examples/dashboard/Example.vue'
<GitHubIcon class="mr-2 h-4 w-4" /> <GitHubIcon class="mr-2 h-4 w-4" />
GitHub GitHub
</a> </a>
</section> </PageAction>
</PageHeader> </PageHeader>
<ExamplesNav /> <ExamplesNav />
<section class="space-y-8 overflow-hidden rounded-lg border-2 border-primary dark:border-muted md:hidden"> <section class="space-y-8 overflow-hidden rounded-lg border-2 border-primary dark:border-muted md:hidden">

View File

@ -0,0 +1,14 @@
<script setup lang="ts">
import { cn } from '@/lib/utils'
</script>
<template>
<section
:class="cn(
'flex w-full items-center justify-center space-x-4 py-4 md:pb-10',
$attrs.class ?? '',
)"
>
<slot />
</section>
</template>

View File

@ -7,7 +7,7 @@ import { cn } from '@/lib/utils'
<template> <template>
<section <section
:class="cn( :class="cn(
'flex max-w-[980px] flex-col items-start gap-2 px-4 pt-8 md:pt-12', 'mx-auto flex max-w-[980px] flex-col items-center gap-2 py-8 md:py-12 md:pb-8 lg:py-24 lg:pb-20',
$attrs.class ?? '', $attrs.class ?? '',
)" )"
> >

View File

@ -4,7 +4,7 @@ import { cn } from '@/lib/utils'
</script> </script>
<template> <template>
<WrapBalancer :class="cn('max-w-[750px] text-lg text-muted-foreground sm:text-xl', $attrs.class ?? '')" :prefer-native="false"> <WrapBalancer :class="cn('max-w-[750px] text-center text-lg text-muted-foreground sm:text-xl', $attrs.class ?? '')" :prefer-native="false">
<slot /> <slot />
</WrapBalancer> </WrapBalancer>
</template> </template>

View File

@ -5,7 +5,7 @@ import { cn } from '@/lib/utils'
<template> <template>
<h1 <h1
:class="cn( :class="cn(
'text-3xl font-bold leading-tight tracking-tighter md:text-5xl lg:leading-[1.1]', 'text-center text-3xl font-bold leading-tight tracking-tighter md:text-6xl lg:leading-[1.1]',
$attrs.class ?? '', $attrs.class ?? '',
)" )"
> >

View File

@ -254,6 +254,12 @@ export const docsConfig: DocsConfig = {
href: '/docs/components/pagination', href: '/docs/components/pagination',
items: [], items: [],
}, },
{
title: 'Pin Input',
href: '/docs/components/pin-input',
label: 'New',
items: [],
},
{ {
title: 'Popover', title: 'Popover',
href: '/docs/components/popover', href: '/docs/components/popover',

View File

@ -15,6 +15,6 @@ export const siteConfig = {
export const announcementConfig = { export const announcementConfig = {
icon: '✨', icon: '✨',
title: 'VSCode extension', title: 'New components!',
link: '/docs/installation.html#vscode-extension', link: '/docs/components/carousel.html',
} }

View File

@ -2,6 +2,7 @@
import PageHeader from '../components/PageHeader.vue' import PageHeader from '../components/PageHeader.vue'
import PageHeaderHeading from '../components/PageHeaderHeading.vue' import PageHeaderHeading from '../components/PageHeaderHeading.vue'
import PageHeaderDescription from '../components/PageHeaderDescription.vue' import PageHeaderDescription from '../components/PageHeaderDescription.vue'
import PageAction from '../components/PageAction.vue'
import ExamplesNav from '../components/ExamplesNav.vue' import ExamplesNav from '../components/ExamplesNav.vue'
import { announcementConfig } from '../config/site' import { announcementConfig } from '../config/site'
import ArrowRightIcon from '~icons/radix-icons/arrow-right' import ArrowRightIcon from '~icons/radix-icons/arrow-right'
@ -36,7 +37,7 @@ import { cn } from '@/lib/utils'
components. Use this as a guide to build your own. components. Use this as a guide to build your own.
</PageHeaderDescription> </PageHeaderDescription>
<section class="flex w-full items-center space-x-4 pb-8 pt-4 md:pb-10"> <PageAction>
<a <a
href="/docs/introduction" href="/docs/introduction"
:class="cn(buttonVariants(), 'rounded-[6px]')" :class="cn(buttonVariants(), 'rounded-[6px]')"
@ -52,7 +53,7 @@ import { cn } from '@/lib/utils'
> >
Components Components
</a> </a>
</section> </PageAction>
</PageHeader> </PageHeader>
<section> <section>
<ExamplesNav /> <ExamplesNav />

View File

@ -138,17 +138,19 @@ watch(() => $route.path, (n) => {
<component :is="link.icon" class="w-[20px] h-5" /> <component :is="link.icon" class="w-[20px] h-5" />
</Button> </Button>
<Button <ClientOnly>
class="flex items-center justify-center" <Button
aria-label="Toggle dark mode" class="flex items-center justify-center"
:variant="'ghost'" aria-label="Toggle dark mode"
:size="'icon'" @click="toggleDark()" :variant="'ghost'"
> :size="'icon'" @click="toggleDark()"
<component >
:is="isDark ? RadixIconsSun : RadixIconsMoon" <component
class="w-[20px] h-5 text-foreground" :is="isDark ? RadixIconsSun : RadixIconsMoon"
/> class="w-[20px] h-5 text-foreground"
</Button> />
</Button>
</ClientOnly>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,10 +1,12 @@
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap");
@tailwind base; @tailwind base;
@tailwind components; @tailwind components;
@tailwind utilities; @tailwind utilities;
@layer base { @layer base {
:root { :root {
--font-geist-sans: "geist-sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
--background: 0 0% 100%; --background: 0 0% 100%;
--foreground: 240 10% 3.9%; --foreground: 240 10% 3.9%;
--card: 0 0% 100%; --card: 0 0% 100%;
@ -68,6 +70,16 @@
-webkit-tap-highlight-color: rgba(128, 128, 128, 0.5); -webkit-tap-highlight-color: rgba(128, 128, 128, 0.5);
} }
/* Font face Geist font */
@font-face {
font-family: "geist-sans";
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url("/fonts/Geist/GeistVariableVF.woff2") format("woff2");
}
/* === Scrollbars === */ /* === Scrollbars === */
::-webkit-scrollbar { ::-webkit-scrollbar {

View File

@ -443,6 +443,13 @@ export const Index = {
component: () => import('../src/lib/registry/default/example/InputWithButton.vue').then(m => m.default), component: () => import('../src/lib/registry/default/example/InputWithButton.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/InputWithButton.vue'], files: ['../src/lib/registry/default/example/InputWithButton.vue'],
}, },
InputWithIcon: {
name: 'InputWithIcon',
type: 'components:example',
registryDependencies: ['input'],
component: () => import('../src/lib/registry/default/example/InputWithIcon.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/InputWithIcon.vue'],
},
InputWithLabel: { InputWithLabel: {
name: 'InputWithLabel', name: 'InputWithLabel',
type: 'components:example', type: 'components:example',
@ -485,6 +492,20 @@ export const Index = {
component: () => import('../src/lib/registry/default/example/PaginationDemo.vue').then(m => m.default), component: () => import('../src/lib/registry/default/example/PaginationDemo.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/PaginationDemo.vue'], files: ['../src/lib/registry/default/example/PaginationDemo.vue'],
}, },
PinInputDemo: {
name: 'PinInputDemo',
type: 'components:example',
registryDependencies: ['pin-input'],
component: () => import('../src/lib/registry/default/example/PinInputDemo.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/PinInputDemo.vue'],
},
PinInputFormDemo: {
name: 'PinInputFormDemo',
type: 'components:example',
registryDependencies: ['pin-input', 'button', 'form', 'toast'],
component: () => import('../src/lib/registry/default/example/PinInputFormDemo.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/PinInputFormDemo.vue'],
},
PopoverDemo: { PopoverDemo: {
name: 'PopoverDemo', name: 'PopoverDemo',
type: 'components:example', type: 'components:example',
@ -1362,6 +1383,13 @@ export const Index = {
component: () => import('../src/lib/registry/new-york/example/InputWithButton.vue').then(m => m.default), component: () => import('../src/lib/registry/new-york/example/InputWithButton.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/InputWithButton.vue'], files: ['../src/lib/registry/new-york/example/InputWithButton.vue'],
}, },
InputWithIcon: {
name: 'InputWithIcon',
type: 'components:example',
registryDependencies: ['input'],
component: () => import('../src/lib/registry/new-york/example/InputWithIcon.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/InputWithIcon.vue'],
},
InputWithLabel: { InputWithLabel: {
name: 'InputWithLabel', name: 'InputWithLabel',
type: 'components:example', type: 'components:example',
@ -1404,6 +1432,20 @@ export const Index = {
component: () => import('../src/lib/registry/new-york/example/PaginationDemo.vue').then(m => m.default), component: () => import('../src/lib/registry/new-york/example/PaginationDemo.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/PaginationDemo.vue'], files: ['../src/lib/registry/new-york/example/PaginationDemo.vue'],
}, },
PinInputDemo: {
name: 'PinInputDemo',
type: 'components:example',
registryDependencies: ['pin-input'],
component: () => import('../src/lib/registry/new-york/example/PinInputDemo.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/PinInputDemo.vue'],
},
PinInputFormDemo: {
name: 'PinInputFormDemo',
type: 'components:example',
registryDependencies: ['pin-input', 'button', 'form', 'toast'],
component: () => import('../src/lib/registry/new-york/example/PinInputFormDemo.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/PinInputFormDemo.vue'],
},
PopoverDemo: { PopoverDemo: {
name: 'PopoverDemo', name: 'PopoverDemo',
type: 'components:example', type: 'components:example',

View File

@ -32,7 +32,7 @@
"embla-carousel-autoplay": "^8.0.0-rc22", "embla-carousel-autoplay": "^8.0.0-rc22",
"embla-carousel-vue": "^8.0.0-rc22", "embla-carousel-vue": "^8.0.0-rc22",
"lucide-vue-next": "^0.276.0", "lucide-vue-next": "^0.276.0",
"radix-vue": "^1.4.1", "radix-vue": "^1.4.6",
"tailwindcss-animate": "^1.0.7", "tailwindcss-animate": "^1.0.7",
"v-calendar": "^3.1.2", "v-calendar": "^3.1.2",
"vee-validate": "4.12.5", "vee-validate": "4.12.5",

View File

@ -63,6 +63,10 @@ import { Input } from '@/components/ui/input'
<ComponentPreview name="InputWithButton" class="max-w-xs" /> <ComponentPreview name="InputWithButton" class="max-w-xs" />
### With Icon
<ComponentPreview name="InputWithIcon" class="max-w-xs" />
### Form ### Form
<ComponentPreview name="InputForm" /> <ComponentPreview name="InputForm" />

View File

@ -0,0 +1,21 @@
---
title: PIN Input
description: Allows users to input a sequence of one-character alphanumeric inputs.
source: apps/www/src/lib/registry/default/ui/pin-input
primitive: https://www.radix-vue.com/components/pin-input.html
---
<ComponentPreview name="PinInputDemo" />
## Installation
```bash
npx shadcn-vue@latest add pin-input
```
## Usage
### Form
<ComponentPreview name="PinInputFormDemo" />

View File

@ -57,7 +57,7 @@ import { Button } from '@/components/ui/button'
}) })
}" }"
> >
Add to calander Add to calendar
</Button> </Button>
</template> </template>
``` ```

View File

@ -61,7 +61,7 @@ const { toast } = useToast()
}); });
}" }"
> >
Add to calander Add to calendar
</Button> </Button>
</template> </template>
``` ```

View File

@ -24,7 +24,7 @@ Install `tailwindcss` and its peer dependencies, then generate your `tailwind.co
<TabsMarkdown> <TabsMarkdown>
<TabMarkdown title="vite.config.ts"> <TabMarkdown title="vite.config">
Vite already has [`postcss`](https://github.com/vitejs/vite/blob/main/packages/vite/package.json#L78) dependency so you don't have to install it again in your package.json Vite already has [`postcss`](https://github.com/vitejs/vite/blob/main/packages/vite/package.json#L78) dependency so you don't have to install it again in your package.json
@ -34,7 +34,7 @@ Install `tailwindcss` and its peer dependencies, then generate your `tailwind.co
#### `vite.config` #### `vite.config`
```typescript {5,6,10-14} ```typescript {5,6,9-13}
import path from "path" import path from "path"
import { defineConfig } from "vite" import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue" import vue from "@vitejs/plugin-vue"
@ -43,13 +43,17 @@ Install `tailwindcss` and its peer dependencies, then generate your `tailwind.co
import autoprefixer from "autoprefixer" import autoprefixer from "autoprefixer"
export default defineConfig({ export default defineConfig({
plugins: [vue()],
css: { css: {
postcss: { postcss: {
plugins: [tailwind(), autoprefixer()], plugins: [tailwind(), autoprefixer()],
}, },
}, },
resolve: {...} plugins: [vue()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
}) })
``` ```
@ -81,10 +85,16 @@ Install `tailwindcss` and its peer dependencies, then generate your `tailwind.co
Add the code below to the compilerOptions of your tsconfig.json so your app can resolve paths without error Add the code below to the compilerOptions of your tsconfig.json so your app can resolve paths without error
```typescript ```json {4-7}
"baseUrl": ".", {
"paths": { "compilerOptions": {
"@/*": ["./src/*"] // ...
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
// ...
}
} }
``` ```
@ -97,12 +107,17 @@ Add the code below to the vite.config.ts so your app can resolve paths without e
npm i -D @types/node npm i -D @types/node
``` ```
```typescript ```typescript {12-16}
import path from "path" import path from "path"
import vue from "@vitejs/plugin-vue" import vue from "@vitejs/plugin-vue"
import { defineConfig } from "vite" import { defineConfig } from "vite"
export default defineConfig({ export default defineConfig({
css: {
postcss: {
plugins: [tailwind(), autoprefixer()],
},
},
plugins: [vue()], plugins: [vue()],
resolve: { resolve: {
alias: { alias: {

View File

@ -0,0 +1,13 @@
<script setup lang="ts">
import { MagnifyingGlassIcon } from '@radix-icons/vue'
import { Input } from '@/lib/registry/default/ui/input'
</script>
<template>
<div class="relative w-full max-w-sm items-center">
<Input id="search" type="text" placeholder="Search..." class="pl-10" />
<span class="absolute start-0 inset-y-0 flex items-center justify-center px-2">
<MagnifyingGlassIcon class="size-6 text-muted-foreground" />
</span>
</div>
</template>

View File

@ -0,0 +1,28 @@
<script setup lang="ts">
import { ref } from 'vue'
import {
PinInput,
PinInputInput,
} from '@/lib/registry/default/ui/pin-input'
const value = ref<string[]>([])
const handleComplete = (e: string[]) => alert(e.join(''))
</script>
<template>
<div>
<PinInput
id="pin-input"
v-model="value"
placeholder="○"
class="flex gap-2 items-center mt-1"
@complete="handleComplete"
>
<PinInputInput
v-for="(id, index) in 5"
:key="id"
:index="index"
/>
</PinInput>
</div>
</template>

View File

@ -0,0 +1,78 @@
<script setup lang="ts">
import { h } from 'vue'
import { useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod'
import * as z from 'zod'
import {
PinInput,
PinInputInput,
} from '@/lib/registry/new-york/ui/pin-input'
import { Button } from '@/lib/registry/default/ui/button'
import {
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from '@/lib/registry/default/ui/form'
import { toast } from '@/lib/registry/default/ui/toast'
const formSchema = toTypedSchema(z.object({
pin: z.array(z.coerce.string()).length(5, { message: 'Invalid input' }),
}))
const { handleSubmit, setValues } = useForm({
validationSchema: formSchema,
initialValues: {
pin: [],
},
})
const onSubmit = handleSubmit(({ pin }) => {
toast({
title: 'You submitted the following values:',
description: h('pre', { class: 'mt-2 w-[340px] rounded-md bg-slate-950 p-4' }, h('code', { class: 'text-white' }, JSON.stringify(pin.join(''), null, 2))),
})
})
const handleComplete = (e: string[]) => console.log(e.join(''))
</script>
<template>
<form class="w-2/3 space-y-6 mx-auto" @submit="onSubmit">
<FormField v-slot="{ componentField }" name="pin">
<FormItem>
<FormLabel>OTP</FormLabel>
<FormControl>
<PinInput
id="pin-input"
placeholder="○"
class="flex gap-2 items-center mt-1"
otp
type="number"
:name="componentField.name"
@complete="handleComplete"
@update:model-value="(arrStr) => {
setValues({
pin: arrStr.filter(Boolean),
})
}"
>
<PinInputInput
v-for="(id, index) in 5"
:key="id"
:index="index"
/>
</PinInput>
</FormControl>
<FormDescription>
Allows users to input a sequence of one-character alphanumeric inputs.
</FormDescription>
<FormMessage />
</FormItem>
</FormField>
<Button>Submit</Button>
</form>
</template>

View File

@ -15,6 +15,6 @@ import { Button } from '@/lib/registry/default/ui/button'
}) })
}" }"
> >
Add to calander Add to calendar
</Button> </Button>
</template> </template>

View File

@ -14,6 +14,6 @@ const { toast } = useToast()
}); });
}" }"
> >
Add to calander Add to calendar
</Button> </Button>
</template> </template>

View File

@ -147,16 +147,10 @@ const vCalendarSlots = computed(() => {
@apply mt-4; @apply mt-4;
} }
.calendar .vc-weekdays { .calendar .vc-weekdays {
@apply flex; @apply justify-items-center;
} }
.calendar .vc-weekday { .calendar .vc-weekday {
@apply text-muted-foreground rounded-md w-full font-normal text-[0.8rem]; @apply text-muted-foreground rounded-md font-normal text-[0.8rem];
}
.calendar .vc-weekday-1 {
@apply pr-3;
}
.calendar .vc-weekday-7 {
@apply pl-3;
} }
.calendar .vc-weeks { .calendar .vc-weeks {
@apply w-full space-y-2 flex flex-col [&>_div]:grid [&>_div]:grid-cols-7; @apply w-full space-y-2 flex flex-col [&>_div]:grid [&>_div]:grid-cols-7;

View File

@ -0,0 +1,21 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { PinInputRoot, type PinInputRootEmits, type PinInputRootProps, useForwardPropsEmits } from 'radix-vue'
import { cn } from '@/lib/utils'
const props = defineProps<PinInputRootProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<PinInputRootEmits>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
const forwarded = useForwardPropsEmits(delegatedProps, emits)
</script>
<template>
<PinInputRoot v-bind="forwarded" :class="cn('flex gap-2 items-center', props.class)">
<slot />
</PinInputRoot>
</template>

View File

@ -0,0 +1,18 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { PinInputInput, type PinInputInputProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils'
const props = defineProps<PinInputInputProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
const forwardedProps = useForwardProps(delegatedProps)
</script>
<template>
<PinInputInput v-bind="forwardedProps" :class="cn('flex w-10 h-10 text-center rounded-md border border-input bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', props.class)" />
</template>

View File

@ -0,0 +1,2 @@
export { default as PinInput } from './PinInput.vue'
export { default as PinInputInput } from './PinInputInput.vue'

View File

@ -31,7 +31,7 @@ const forwardedProps = useForwardProps(delegatedProps)
) )
" "
> >
<span class="absolute right-2 flex h-3.5 w-3.5 items-center justify-center"> <span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<SelectItemIndicator> <SelectItemIndicator>
<Check class="h-4 w-4" /> <Check class="h-4 w-4" />
</SelectItemIndicator> </SelectItemIndicator>

View File

@ -0,0 +1,13 @@
<script setup lang="ts">
import { MagnifyingGlassIcon } from '@radix-icons/vue'
import { Input } from '@/lib/registry/new-york/ui/input'
</script>
<template>
<div class="relative w-full max-w-sm items-center">
<Input id="search" type="text" placeholder="Search..." class="pl-10" />
<span class="absolute start-0 inset-y-0 flex items-center justify-center px-2">
<MagnifyingGlassIcon class="size-6 text-muted-foreground" />
</span>
</div>
</template>

View File

@ -0,0 +1,28 @@
<script setup lang="ts">
import { ref } from 'vue'
import {
PinInput,
PinInputInput,
} from '@/lib/registry/new-york/ui/pin-input'
const value = ref<string[]>([])
function handleComplete() {
console.log('212121')
}
</script>
<template>
<PinInput
id="pin-input"
v-model="value"
placeholder="○"
class="flex gap-2 items-center mt-1"
@complete="handleComplete"
>
<PinInputInput
v-for="(id, index) in 5"
:key="id"
:index="index"
/>
</PinInput>
</template>

View File

@ -0,0 +1,78 @@
<script setup lang="ts">
import { h } from 'vue'
import { useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod'
import * as z from 'zod'
import {
PinInput,
PinInputInput,
} from '@/lib/registry/new-york/ui/pin-input'
import { Button } from '@/lib/registry/new-york/ui/button'
import {
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from '@/lib/registry/new-york/ui/form'
import { toast } from '@/lib/registry/new-york/ui/toast'
const formSchema = toTypedSchema(z.object({
pin: z.array(z.coerce.string()).length(5, { message: 'Invalid input' }),
}))
const { handleSubmit, setValues } = useForm({
validationSchema: formSchema,
initialValues: {
pin: [],
},
})
const onSubmit = handleSubmit(({ pin }) => {
toast({
title: 'You submitted the following values:',
description: h('pre', { class: 'mt-2 w-[340px] rounded-md bg-slate-950 p-4' }, h('code', { class: 'text-white' }, JSON.stringify(pin.join(''), null, 2))),
})
})
const handleComplete = (e: string[]) => console.log(e.join(''))
</script>
<template>
<form class="w-2/3 space-y-6 mx-auto" @submit="onSubmit">
<FormField v-slot="{ componentField }" name="pin">
<FormItem>
<FormLabel>OTP</FormLabel>
<FormControl>
<PinInput
id="pin-input"
placeholder="○"
class="flex gap-2 items-center mt-1"
otp
type="number"
:name="componentField.name"
@complete="handleComplete"
@update:model-value="(arrStr) => {
setValues({
pin: arrStr.filter(Boolean),
})
}"
>
<PinInputInput
v-for="(id, index) in 5"
:key="id"
:index="index"
/>
</PinInput>
</FormControl>
<FormDescription>
Allows users to input a sequence of one-character alphanumeric inputs.
</FormDescription>
<FormMessage />
</FormItem>
</FormField>
<Button>Submit</Button>
</form>
</template>

View File

@ -15,6 +15,6 @@ import { Button } from '@/lib/registry/new-york/ui/button'
}) })
}" }"
> >
Add to calander Add to calendar
</Button> </Button>
</template> </template>

View File

@ -14,6 +14,6 @@ const { toast } = useToast()
}); });
}" }"
> >
Add to calander Add to calendar
</Button> </Button>
</template> </template>

View File

@ -148,16 +148,10 @@ const vCalendarSlots = computed(() => {
@apply mt-4; @apply mt-4;
} }
.calendar .vc-weekdays { .calendar .vc-weekdays {
@apply flex; @apply justify-items-center;
} }
.calendar .vc-weekday { .calendar .vc-weekday {
@apply text-muted-foreground rounded-md w-full font-normal text-[0.8rem]; @apply text-muted-foreground rounded-md font-normal text-[0.8rem];
}
.calendar .vc-weekday-1 {
@apply pr-3;
}
.calendar .vc-weekday-7 {
@apply pl-3;
} }
.calendar .vc-weeks { .calendar .vc-weeks {
@apply w-full space-y-2 flex flex-col [&>_div]:grid [&>_div]:grid-cols-7; @apply w-full space-y-2 flex flex-col [&>_div]:grid [&>_div]:grid-cols-7;

View File

@ -0,0 +1,21 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { PinInputRoot, type PinInputRootEmits, type PinInputRootProps, useForwardPropsEmits } from 'radix-vue'
import { cn } from '@/lib/utils'
const props = defineProps<PinInputRootProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<PinInputRootEmits>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
const forwarded = useForwardPropsEmits(delegatedProps, emits)
</script>
<template>
<PinInputRoot v-bind="forwarded" :class="cn('flex gap-2 items-center', props.class)">
<slot />
</PinInputRoot>
</template>

View File

@ -0,0 +1,18 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { PinInputInput, type PinInputInputProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils'
const props = defineProps<PinInputInputProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
const forwardedProps = useForwardProps(delegatedProps)
</script>
<template>
<PinInputInput v-bind="forwardedProps" :class="cn('flex w-10 h-10 text-center rounded-md border border-input bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', props.class)" />
</template>

View File

@ -0,0 +1,2 @@
export { default as PinInput } from './PinInput.vue'
export { default as PinInputInput } from './PinInputInput.vue'

Binary file not shown.

View File

@ -0,0 +1,92 @@
Geist Sans and Geist Mono Font
(C) 2023 Vercel, made in collaboration with basement.studio
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is available with a FAQ at: http://scripts.sil.org/OFL and copied below
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION AND CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@ -392,6 +392,19 @@
], ],
"type": "components:ui" "type": "components:ui"
}, },
{
"name": "pin-input",
"dependencies": [],
"registryDependencies": [
"utils"
],
"files": [
"ui/pin-input/PinInput.vue",
"ui/pin-input/PinInputInput.vue",
"ui/pin-input/index.ts"
],
"type": "components:ui"
},
{ {
"name": "popover", "name": "popover",
"dependencies": [], "dependencies": [],

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,22 @@
{
"name": "pin-input",
"dependencies": [],
"registryDependencies": [
"utils"
],
"files": [
{
"name": "PinInput.vue",
"content": "<script setup lang=\"ts\">\nimport { type HTMLAttributes, computed } from 'vue'\nimport { PinInputRoot, type PinInputRootEmits, type PinInputRootProps, useForwardPropsEmits } from 'radix-vue'\nimport { cn } from '@/lib/utils'\n\nconst props = defineProps<PinInputRootProps & { class?: HTMLAttributes['class'] }>()\nconst emits = defineEmits<PinInputRootEmits>()\n\nconst delegatedProps = computed(() => {\n const { class: _, ...delegated } = props\n return delegated\n})\n\nconst forwarded = useForwardPropsEmits(delegatedProps, emits)\n</script>\n\n<template>\n <PinInputRoot v-bind=\"forwarded\" :class=\"cn('flex gap-2 items-center', props.class)\">\n <slot />\n </PinInputRoot>\n</template>\n"
},
{
"name": "PinInputInput.vue",
"content": "<script setup lang=\"ts\">\nimport { type HTMLAttributes, computed } from 'vue'\nimport { PinInputInput, type PinInputInputProps, useForwardProps } from 'radix-vue'\nimport { cn } from '@/lib/utils'\n\nconst props = defineProps<PinInputInputProps & { class?: HTMLAttributes['class'] }>()\n\nconst delegatedProps = computed(() => {\n const { class: _, ...delegated } = props\n return delegated\n})\n\nconst forwardedProps = useForwardProps(delegatedProps)\n</script>\n\n<template>\n <PinInputInput v-bind=\"forwardedProps\" :class=\"cn('flex w-10 h-10 text-center rounded-md border border-input bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', props.class)\" />\n</template>\n"
},
{
"name": "index.ts",
"content": "export { default as PinInput } from './PinInput.vue'\nexport { default as PinInputInput } from './PinInputInput.vue'\n"
}
],
"type": "components:ui"
}

View File

@ -19,7 +19,7 @@
}, },
{ {
"name": "SelectItem.vue", "name": "SelectItem.vue",
"content": "<script setup lang=\"ts\">\nimport { type HTMLAttributes, computed } from 'vue'\nimport {\n SelectItem,\n SelectItemIndicator,\n type SelectItemProps,\n SelectItemText,\n useForwardProps,\n} from 'radix-vue'\nimport { Check } from 'lucide-vue-next'\nimport { cn } from '@/lib/utils'\n\nconst props = defineProps<SelectItemProps & { class?: HTMLAttributes['class'] }>()\n\nconst delegatedProps = computed(() => {\n const { class: _, ...delegated } = props\n\n return delegated\n})\n\nconst forwardedProps = useForwardProps(delegatedProps)\n</script>\n\n<template>\n <SelectItem\n v-bind=\"forwardedProps\"\n :class=\"\n cn(\n 'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n props.class,\n )\n \"\n >\n <span class=\"absolute right-2 flex h-3.5 w-3.5 items-center justify-center\">\n <SelectItemIndicator>\n <Check class=\"h-4 w-4\" />\n </SelectItemIndicator>\n </span>\n\n <SelectItemText>\n <slot />\n </SelectItemText>\n </SelectItem>\n</template>\n" "content": "<script setup lang=\"ts\">\nimport { type HTMLAttributes, computed } from 'vue'\nimport {\n SelectItem,\n SelectItemIndicator,\n type SelectItemProps,\n SelectItemText,\n useForwardProps,\n} from 'radix-vue'\nimport { Check } from 'lucide-vue-next'\nimport { cn } from '@/lib/utils'\n\nconst props = defineProps<SelectItemProps & { class?: HTMLAttributes['class'] }>()\n\nconst delegatedProps = computed(() => {\n const { class: _, ...delegated } = props\n\n return delegated\n})\n\nconst forwardedProps = useForwardProps(delegatedProps)\n</script>\n\n<template>\n <SelectItem\n v-bind=\"forwardedProps\"\n :class=\"\n cn(\n 'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n props.class,\n )\n \"\n >\n <span class=\"absolute left-2 flex h-3.5 w-3.5 items-center justify-center\">\n <SelectItemIndicator>\n <Check class=\"h-4 w-4\" />\n </SelectItemIndicator>\n </span>\n\n <SelectItemText>\n <slot />\n </SelectItemText>\n </SelectItem>\n</template>\n"
}, },
{ {
"name": "SelectItemText.vue", "name": "SelectItemText.vue",

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,22 @@
{
"name": "pin-input",
"dependencies": [],
"registryDependencies": [
"utils"
],
"files": [
{
"name": "PinInput.vue",
"content": "<script setup lang=\"ts\">\nimport { type HTMLAttributes, computed } from 'vue'\nimport { PinInputRoot, type PinInputRootEmits, type PinInputRootProps, useForwardPropsEmits } from 'radix-vue'\nimport { cn } from '@/lib/utils'\n\nconst props = defineProps<PinInputRootProps & { class?: HTMLAttributes['class'] }>()\nconst emits = defineEmits<PinInputRootEmits>()\n\nconst delegatedProps = computed(() => {\n const { class: _, ...delegated } = props\n return delegated\n})\n\nconst forwarded = useForwardPropsEmits(delegatedProps, emits)\n</script>\n\n<template>\n <PinInputRoot v-bind=\"forwarded\" :class=\"cn('flex gap-2 items-center', props.class)\">\n <slot />\n </PinInputRoot>\n</template>\n"
},
{
"name": "PinInputInput.vue",
"content": "<script setup lang=\"ts\">\nimport { type HTMLAttributes, computed } from 'vue'\nimport { PinInputInput, type PinInputInputProps, useForwardProps } from 'radix-vue'\nimport { cn } from '@/lib/utils'\n\nconst props = defineProps<PinInputInputProps & { class?: HTMLAttributes['class'] }>()\n\nconst delegatedProps = computed(() => {\n const { class: _, ...delegated } = props\n return delegated\n})\n\nconst forwardedProps = useForwardProps(delegatedProps)\n</script>\n\n<template>\n <PinInputInput v-bind=\"forwardedProps\" :class=\"cn('flex w-10 h-10 text-center rounded-md border border-input bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', props.class)\" />\n</template>\n"
},
{
"name": "index.ts",
"content": "export { default as PinInput } from './PinInput.vue'\nexport { default as PinInputInput } from './PinInputInput.vue'\n"
}
],
"type": "components:ui"
}

View File

@ -1,3 +1,4 @@
import defaultTheme from 'tailwindcss/defaultTheme'
import tailwindcssAnimate from 'tailwindcss-animate' import tailwindcssAnimate from 'tailwindcss-animate'
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
@ -13,6 +14,9 @@ export default {
}, },
}, },
extend: { extend: {
fontFamily: {
sans: ['var(--font-geist-sans)', ...defaultTheme.fontFamily.sans],
},
colors: { colors: {
border: 'hsl(var(--border))', border: 'hsl(var(--border))',
input: 'hsl(var(--input))', input: 'hsl(var(--input))',

View File

@ -63,7 +63,7 @@
"node-fetch": "^3.3.2", "node-fetch": "^3.3.2",
"ora": "^7.0.1", "ora": "^7.0.1",
"prompts": "^2.4.2", "prompts": "^2.4.2",
"radix-vue": "^1.4.1", "radix-vue": "^1.4.6",
"recast": "^0.23.4", "recast": "^0.23.4",
"rimraf": "^5.0.1", "rimraf": "^5.0.1",
"ts-morph": "^19.0.0", "ts-morph": "^19.0.0",

View File

@ -13,7 +13,7 @@
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.0.0", "clsx": "^2.0.0",
"lucide-vue-next": "^0.276.0", "lucide-vue-next": "^0.276.0",
"radix-vue": "^1.4.1", "radix-vue": "^1.4.6",
"tailwind-merge": "^1.14.0", "tailwind-merge": "^1.14.0",
"tailwindcss-animate": "^1.0.7" "tailwindcss-animate": "^1.0.7"
}, },

View File

@ -14,7 +14,7 @@
"embla-carousel": "8.0.0-rc19", "embla-carousel": "8.0.0-rc19",
"embla-carousel-vue": "8.0.0-rc19", "embla-carousel-vue": "8.0.0-rc19",
"lucide-vue-next": "^0.276.0", "lucide-vue-next": "^0.276.0",
"radix-vue": "^1.4.1", "radix-vue": "^1.4.6",
"tailwind-merge": "^2.0.0", "tailwind-merge": "^2.0.0",
"tailwindcss-animate": "^1.0.7" "tailwindcss-animate": "^1.0.7"
}, },

View File

@ -96,8 +96,8 @@ importers:
specifier: ^0.276.0 specifier: ^0.276.0
version: 0.276.0(vue@3.4.15) version: 0.276.0(vue@3.4.15)
radix-vue: radix-vue:
specifier: ^1.4.1 specifier: ^1.4.6
version: 1.4.1(vue@3.4.15) version: 1.4.6(vue@3.4.15)
tailwindcss-animate: tailwindcss-animate:
specifier: ^1.0.7 specifier: ^1.0.7
version: 1.0.7(tailwindcss@3.4.1) version: 1.0.7(tailwindcss@3.4.1)
@ -256,8 +256,8 @@ importers:
specifier: ^2.4.2 specifier: ^2.4.2
version: 2.4.2 version: 2.4.2
radix-vue: radix-vue:
specifier: ^1.4.1 specifier: ^1.4.6
version: 1.4.1(vue@3.4.15) version: 1.4.6(vue@3.4.15)
recast: recast:
specifier: ^0.23.4 specifier: ^0.23.4
version: 0.23.4 version: 0.23.4
@ -10848,8 +10848,8 @@ packages:
resolution: {integrity: sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==} resolution: {integrity: sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==}
dev: false dev: false
/radix-vue@1.4.1(vue@3.4.15): /radix-vue@1.4.6(vue@3.4.15):
resolution: {integrity: sha512-eJsyIHDZPfIdH0iqrfTODuklPqDXfO0iNDNI1isOYIr+ejmeCjP6Yw1LA7LtDryPnjsSkqj0t04DF7eBn2wtMQ==} resolution: {integrity: sha512-PWM4A0xyQV4bu8R+DfAGGEN4zRTM0Qer5rH+gLnQjjsz0kjteZhVOS0KUkpyrKVPprWFYRNqyzpjjkcYBDrlfQ==}
dependencies: dependencies:
'@floating-ui/dom': 1.6.1 '@floating-ui/dom': 1.6.1
'@floating-ui/vue': 1.0.6(vue@3.4.15) '@floating-ui/vue': 1.0.6(vue@3.4.15)