@personizely/ui 0.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +1 -0
  3. package/dist/personizely-ui.css +6 -0
  4. package/dist/personizely-ui.js +26854 -0
  5. package/dist/personizely-ui.umd.cjs +111 -0
  6. package/package.json +117 -0
  7. package/src/assets/index.css +136 -0
  8. package/src/components/ui/accordion/Accordion.vue +19 -0
  9. package/src/components/ui/accordion/AccordionContent.vue +24 -0
  10. package/src/components/ui/accordion/AccordionItem.vue +37 -0
  11. package/src/components/ui/accordion/AccordionTrigger.vue +39 -0
  12. package/src/components/ui/accordion/index.ts +2 -0
  13. package/src/components/ui/alert/Alert.vue +68 -0
  14. package/src/components/ui/alert/index.ts +22 -0
  15. package/src/components/ui/alert-dialog/AlertDialog.vue +66 -0
  16. package/src/components/ui/alert-dialog/AlertDialogContent.vue +44 -0
  17. package/src/components/ui/alert-dialog/AlertDialogProvider.vue +27 -0
  18. package/src/components/ui/alert-dialog/AlertDialogTrigger.vue +11 -0
  19. package/src/components/ui/alert-dialog/index.ts +3 -0
  20. package/src/components/ui/alert-dialog/useAlertDialog.ts +19 -0
  21. package/src/components/ui/autocomplete/Autocomplete.vue +170 -0
  22. package/src/components/ui/autocomplete/AutocompleteContent.vue +27 -0
  23. package/src/components/ui/autocomplete/AutocompleteEmpty.vue +20 -0
  24. package/src/components/ui/autocomplete/AutocompleteGroup.vue +29 -0
  25. package/src/components/ui/autocomplete/AutocompleteItem.vue +26 -0
  26. package/src/components/ui/autocomplete/AutocompleteRoot.vue +31 -0
  27. package/src/components/ui/autocomplete/AutocompleteSeparator.vue +23 -0
  28. package/src/components/ui/autocomplete/index.ts +1 -0
  29. package/src/components/ui/avatar/Avatar.vue +31 -0
  30. package/src/components/ui/avatar/AvatarFallback.vue +11 -0
  31. package/src/components/ui/avatar/AvatarImage.vue +9 -0
  32. package/src/components/ui/avatar/index.ts +19 -0
  33. package/src/components/ui/badge/Badge.vue +16 -0
  34. package/src/components/ui/badge/index.ts +22 -0
  35. package/src/components/ui/button/Button.vue +123 -0
  36. package/src/components/ui/button/index.ts +78 -0
  37. package/src/components/ui/calendar/Calendar.vue +76 -0
  38. package/src/components/ui/calendar/CalendarCell.vue +24 -0
  39. package/src/components/ui/calendar/CalendarCellTrigger.vue +38 -0
  40. package/src/components/ui/calendar/CalendarGrid.vue +24 -0
  41. package/src/components/ui/calendar/CalendarGridBody.vue +11 -0
  42. package/src/components/ui/calendar/CalendarGridHead.vue +11 -0
  43. package/src/components/ui/calendar/CalendarGridRow.vue +21 -0
  44. package/src/components/ui/calendar/CalendarHeadCell.vue +21 -0
  45. package/src/components/ui/calendar/CalendarHeader.vue +21 -0
  46. package/src/components/ui/calendar/CalendarHeading.vue +27 -0
  47. package/src/components/ui/calendar/CalendarNextButton.vue +32 -0
  48. package/src/components/ui/calendar/CalendarPrevButton.vue +32 -0
  49. package/src/components/ui/calendar/index.ts +1 -0
  50. package/src/components/ui/card/Card.vue +57 -0
  51. package/src/components/ui/card/CardContent.vue +14 -0
  52. package/src/components/ui/card/CardDescription.vue +14 -0
  53. package/src/components/ui/card/CardFooter.vue +14 -0
  54. package/src/components/ui/card/CardHeader.vue +14 -0
  55. package/src/components/ui/card/CardTitle.vue +18 -0
  56. package/src/components/ui/card/CardTray.vue +14 -0
  57. package/src/components/ui/card/index.ts +1 -0
  58. package/src/components/ui/checkbox/Checkbox.vue +63 -0
  59. package/src/components/ui/checkbox/CheckboxBase.vue +39 -0
  60. package/src/components/ui/checkbox/index.ts +1 -0
  61. package/src/components/ui/checkbox-group/CheckboxGroup.vue +65 -0
  62. package/src/components/ui/checkbox-group/index.ts +15 -0
  63. package/src/components/ui/color-picker/Alpha.vue +63 -0
  64. package/src/components/ui/color-picker/Angle.vue +145 -0
  65. package/src/components/ui/color-picker/Checkboard.vue +43 -0
  66. package/src/components/ui/color-picker/Color.vue +255 -0
  67. package/src/components/ui/color-picker/ColorPicker.vue +25 -0
  68. package/src/components/ui/color-picker/Gradient.vue +172 -0
  69. package/src/components/ui/color-picker/Handle.vue +19 -0
  70. package/src/components/ui/color-picker/Hue.vue +80 -0
  71. package/src/components/ui/color-picker/LabelInput.vue +16 -0
  72. package/src/components/ui/color-picker/Rail.vue +100 -0
  73. package/src/components/ui/color-picker/Saturation.vue +142 -0
  74. package/src/components/ui/color-picker/index.ts +4 -0
  75. package/src/components/ui/combobox/Combobox.vue +202 -0
  76. package/src/components/ui/combobox/ComboboxContent.vue +27 -0
  77. package/src/components/ui/combobox/ComboboxEmpty.vue +20 -0
  78. package/src/components/ui/combobox/ComboboxGroup.vue +29 -0
  79. package/src/components/ui/combobox/ComboboxInput.vue +52 -0
  80. package/src/components/ui/combobox/ComboboxItem.vue +26 -0
  81. package/src/components/ui/combobox/ComboboxRoot.vue +31 -0
  82. package/src/components/ui/combobox/ComboboxSeparator.vue +23 -0
  83. package/src/components/ui/combobox/index.ts +1 -0
  84. package/src/components/ui/date-picker/DatePicker.vue +55 -0
  85. package/src/components/ui/date-picker/index.ts +1 -0
  86. package/src/components/ui/date-range-picker/DateRangePicker.vue +137 -0
  87. package/src/components/ui/date-range-picker/index.ts +1 -0
  88. package/src/components/ui/dialog/Dialog.vue +78 -0
  89. package/src/components/ui/dialog/DialogContent.vue +46 -0
  90. package/src/components/ui/dialog/DialogDescription.vue +24 -0
  91. package/src/components/ui/dialog/DialogFooter.vue +19 -0
  92. package/src/components/ui/dialog/DialogHeader.vue +16 -0
  93. package/src/components/ui/dialog/DialogTitle.vue +29 -0
  94. package/src/components/ui/dialog/DialogTrigger.vue +11 -0
  95. package/src/components/ui/dialog/index.ts +1 -0
  96. package/src/components/ui/drawer/Drawer.vue +88 -0
  97. package/src/components/ui/drawer/DrawerContent.vue +57 -0
  98. package/src/components/ui/drawer/DrawerDescription.vue +22 -0
  99. package/src/components/ui/drawer/DrawerFooter.vue +19 -0
  100. package/src/components/ui/drawer/DrawerHeader.vue +16 -0
  101. package/src/components/ui/drawer/DrawerTitle.vue +22 -0
  102. package/src/components/ui/drawer/DrawerTrigger.vue +11 -0
  103. package/src/components/ui/drawer/index.ts +21 -0
  104. package/src/components/ui/dropdown-menu/DropdownCheckboxGroupMenu.vue +87 -0
  105. package/src/components/ui/dropdown-menu/DropdownMenu.vue +72 -0
  106. package/src/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +40 -0
  107. package/src/components/ui/dropdown-menu/DropdownMenuContent.vue +37 -0
  108. package/src/components/ui/dropdown-menu/DropdownMenuGroup.vue +11 -0
  109. package/src/components/ui/dropdown-menu/DropdownMenuHelp.vue +14 -0
  110. package/src/components/ui/dropdown-menu/DropdownMenuItem.vue +28 -0
  111. package/src/components/ui/dropdown-menu/DropdownMenuLabel.vue +24 -0
  112. package/src/components/ui/dropdown-menu/DropdownMenuPart.vue +64 -0
  113. package/src/components/ui/dropdown-menu/DropdownMenuPartItem.vue +76 -0
  114. package/src/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +19 -0
  115. package/src/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +41 -0
  116. package/src/components/ui/dropdown-menu/DropdownMenuSeparator.vue +22 -0
  117. package/src/components/ui/dropdown-menu/DropdownMenuShortcut.vue +14 -0
  118. package/src/components/ui/dropdown-menu/DropdownMenuSub.vue +19 -0
  119. package/src/components/ui/dropdown-menu/DropdownMenuSubContent.vue +30 -0
  120. package/src/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +33 -0
  121. package/src/components/ui/dropdown-menu/DropdownMenuTrigger.vue +13 -0
  122. package/src/components/ui/dropdown-menu/DropdownRadioGroupMenu.vue +75 -0
  123. package/src/components/ui/dropdown-menu/index.ts +36 -0
  124. package/src/components/ui/file-upload-button/FileUploadButton.vue +55 -0
  125. package/src/components/ui/file-upload-button/index.ts +1 -0
  126. package/src/components/ui/form/Form.vue +13 -0
  127. package/src/components/ui/form/FormControl.vue +16 -0
  128. package/src/components/ui/form/FormDescription.vue +20 -0
  129. package/src/components/ui/form/FormField.vue +61 -0
  130. package/src/components/ui/form/FormLabel.vue +23 -0
  131. package/src/components/ui/form/FormMessage.vue +16 -0
  132. package/src/components/ui/form/index.ts +2 -0
  133. package/src/components/ui/form/useFormField.ts +30 -0
  134. package/src/components/ui/icon/Icon.vue +16 -0
  135. package/src/components/ui/icon/index.ts +1 -0
  136. package/src/components/ui/input/Input.vue +51 -0
  137. package/src/components/ui/input/InputBase.vue +18 -0
  138. package/src/components/ui/input/index.ts +1 -0
  139. package/src/components/ui/label/Label.vue +27 -0
  140. package/src/components/ui/label/index.ts +1 -0
  141. package/src/components/ui/pagination/Pagination.vue +50 -0
  142. package/src/components/ui/pagination/PaginationContent.vue +21 -0
  143. package/src/components/ui/pagination/PaginationEllipsis.vue +24 -0
  144. package/src/components/ui/pagination/PaginationFirst.vue +32 -0
  145. package/src/components/ui/pagination/PaginationItem.vue +32 -0
  146. package/src/components/ui/pagination/PaginationLast.vue +32 -0
  147. package/src/components/ui/pagination/PaginationNext.vue +32 -0
  148. package/src/components/ui/pagination/PaginationPrevious.vue +32 -0
  149. package/src/components/ui/pagination/index.ts +1 -0
  150. package/src/components/ui/popover/Popover.vue +57 -0
  151. package/src/components/ui/popover/PopoverTrigger.vue +15 -0
  152. package/src/components/ui/popover/index.ts +1 -0
  153. package/src/components/ui/progress/Progress.vue +35 -0
  154. package/src/components/ui/progress/ProgressIndicator.vue +19 -0
  155. package/src/components/ui/progress/index.ts +2 -0
  156. package/src/components/ui/progress-circular/ProgressCircular.vue +85 -0
  157. package/src/components/ui/progress-circular/index.ts +1 -0
  158. package/src/components/ui/radio-group/RadioGroup.vue +81 -0
  159. package/src/components/ui/radio-group/RadioGroupItem.vue +39 -0
  160. package/src/components/ui/radio-group/index.ts +15 -0
  161. package/src/components/ui/range-calendar/RangeCalendar.vue +71 -0
  162. package/src/components/ui/range-calendar/RangeCalendarCell.vue +28 -0
  163. package/src/components/ui/range-calendar/RangeCalendarCellTrigger.vue +40 -0
  164. package/src/components/ui/range-calendar/RangeCalendarGrid.vue +24 -0
  165. package/src/components/ui/range-calendar/RangeCalendarGridBody.vue +11 -0
  166. package/src/components/ui/range-calendar/RangeCalendarGridHead.vue +11 -0
  167. package/src/components/ui/range-calendar/RangeCalendarGridRow.vue +21 -0
  168. package/src/components/ui/range-calendar/RangeCalendarHeadCell.vue +21 -0
  169. package/src/components/ui/range-calendar/RangeCalendarHeader.vue +21 -0
  170. package/src/components/ui/range-calendar/RangeCalendarHeading.vue +27 -0
  171. package/src/components/ui/range-calendar/RangeCalendarNextButton.vue +32 -0
  172. package/src/components/ui/range-calendar/RangeCalendarPrevButton.vue +32 -0
  173. package/src/components/ui/range-calendar/index.ts +1 -0
  174. package/src/components/ui/select/Select.vue +120 -0
  175. package/src/components/ui/select/SelectContent.vue +45 -0
  176. package/src/components/ui/select/SelectGroup.vue +19 -0
  177. package/src/components/ui/select/SelectItem.vue +43 -0
  178. package/src/components/ui/select/SelectLabel.vue +13 -0
  179. package/src/components/ui/select/SelectSeparator.vue +17 -0
  180. package/src/components/ui/select/SelectTrigger.vue +31 -0
  181. package/src/components/ui/select/SelectValue.vue +11 -0
  182. package/src/components/ui/select/index.ts +1 -0
  183. package/src/components/ui/slider/Slider.vue +100 -0
  184. package/src/components/ui/slider/index.ts +1 -0
  185. package/src/components/ui/switch/Switch.vue +40 -0
  186. package/src/components/ui/switch/SwitchBase.vue +36 -0
  187. package/src/components/ui/switch/index.ts +1 -0
  188. package/src/components/ui/tabs/Tabs.vue +63 -0
  189. package/src/components/ui/tabs/TabsContent.vue +26 -0
  190. package/src/components/ui/tabs/TabsTrigger.vue +27 -0
  191. package/src/components/ui/tabs/index.ts +28 -0
  192. package/src/components/ui/textarea/Textarea.vue +13 -0
  193. package/src/components/ui/textarea/index.ts +1 -0
  194. package/src/components/ui/toast/Toast.vue +28 -0
  195. package/src/components/ui/toast/ToastAction.vue +26 -0
  196. package/src/components/ui/toast/ToastClose.vue +29 -0
  197. package/src/components/ui/toast/ToastDescription.vue +19 -0
  198. package/src/components/ui/toast/ToastProvider.vue +11 -0
  199. package/src/components/ui/toast/ToastTitle.vue +19 -0
  200. package/src/components/ui/toast/ToastViewport.vue +17 -0
  201. package/src/components/ui/toast/Toaster.vue +30 -0
  202. package/src/components/ui/toast/index.ts +34 -0
  203. package/src/components/ui/toast/useToast.ts +163 -0
  204. package/src/components/ui/toggle/Toggle.vue +51 -0
  205. package/src/components/ui/toggle/index.ts +71 -0
  206. package/src/components/ui/toggle-group/ToggleGroup.vue +58 -0
  207. package/src/components/ui/toggle-group/ToggleGroupItem.vue +54 -0
  208. package/src/components/ui/toggle-group/index.ts +1 -0
  209. package/src/components/ui/tooltip/Tooltip.vue +42 -0
  210. package/src/components/ui/tooltip/TooltipProvider.vue +11 -0
  211. package/src/components/ui/tooltip/index.ts +2 -0
  212. package/src/composables/delegated-props.ts +6 -0
  213. package/src/composables/emits-as-props.ts +17 -0
  214. package/src/composables/forward-props-emits.ts +11 -0
  215. package/src/directives/autofocus.ts +7 -0
  216. package/src/index.ts +159 -0
  217. package/src/options-provider.ts +19 -0
  218. package/src/utils/gradient.ts +158 -0
  219. package/src/utils/options.ts +40 -0
  220. package/src/utils/tailwind.ts +14 -0
  221. package/web-types.json +10560 -0
@@ -0,0 +1,28 @@
1
+ <template>
2
+ <ToastRoot
3
+ v-bind="forwarded"
4
+ :class="cn(toastVariants({ variant }), props.class)"
5
+ @update:open="onOpenChange"
6
+ >
7
+ <slot />
8
+ </ToastRoot>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import { computed } from 'vue'
13
+ import { ToastRoot, type ToastRootEmits, useForwardPropsEmits } from 'reka-ui'
14
+ import { type ToastProps, toastVariants } from '.'
15
+ import { cn } from '@/utils/tailwind'
16
+
17
+ const props = defineProps<ToastProps>()
18
+
19
+ const emits = defineEmits<ToastRootEmits>()
20
+
21
+ const delegatedProps = computed(() => {
22
+ const { class: _, ...delegated } = props
23
+
24
+ return delegated
25
+ })
26
+
27
+ const forwarded = useForwardPropsEmits(delegatedProps, emits)
28
+ </script>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <ToastAction v-bind="delegatedProps" as-child>
3
+ <Button
4
+ size="sm"
5
+ :class="props.class"
6
+ :variant="variant === 'destructive' ? 'destructive' : 'ghost'"
7
+ >
8
+ <slot />
9
+ </Button>
10
+ </ToastAction>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ import { type HTMLAttributes, computed } from 'vue'
15
+ import { ToastAction, type ToastActionProps } from 'reka-ui'
16
+ import { Button } from '@/components/ui/button'
17
+ import type { ToastVariants } from './'
18
+
19
+ const props = defineProps<ToastActionProps & { class?: HTMLAttributes['class'], variant: ToastVariants['variant'] }>()
20
+
21
+ const delegatedProps = computed(() => {
22
+ const { class: _, ...delegated } = props
23
+
24
+ return delegated
25
+ })
26
+ </script>
@@ -0,0 +1,29 @@
1
+ <template>
2
+ <ToastClose v-bind="delegatedProps" as-child>
3
+ <Button
4
+ size="xs"
5
+ icon="x"
6
+ :variant="variant === 'destructive' ? 'destructive' : 'ghost'"
7
+ :class="cn('absolute right-2 top-2 opacity-0 group-hover:opacity-100 transition-opacity focus:opacity-100', props.class)"
8
+ />
9
+ </ToastClose>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import { type HTMLAttributes, computed } from 'vue'
14
+ import { ToastClose, type ToastCloseProps } from 'reka-ui'
15
+ import { cn } from '@/utils/tailwind'
16
+ import { Button } from '@/components/ui/button'
17
+ import type { ToastVariants } from './'
18
+
19
+ const props = defineProps<ToastCloseProps & {
20
+ class?: HTMLAttributes['class'],
21
+ variant: ToastVariants['variant']
22
+ }>()
23
+
24
+ const delegatedProps = computed(() => {
25
+ const { class: _, ...delegated } = props
26
+
27
+ return delegated
28
+ })
29
+ </script>
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <ToastDescription :class="cn('text-xs opacity-90', props.class)" v-bind="delegatedProps">
3
+ <slot />
4
+ </ToastDescription>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { type HTMLAttributes, computed } from 'vue'
9
+ import { ToastDescription, type ToastDescriptionProps } from 'reka-ui'
10
+ import { cn } from '@/utils/tailwind'
11
+
12
+ const props = defineProps<ToastDescriptionProps & { class?: HTMLAttributes['class'] }>()
13
+
14
+ const delegatedProps = computed(() => {
15
+ const { class: _, ...delegated } = props
16
+
17
+ return delegated
18
+ })
19
+ </script>
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <ToastProvider v-bind="props">
3
+ <slot />
4
+ </ToastProvider>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { ToastProvider, type ToastProviderProps } from 'reka-ui'
9
+
10
+ const props = defineProps<ToastProviderProps>()
11
+ </script>
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <ToastTitle v-bind="delegatedProps" :class="cn('text-xs font-medium', props.class)">
3
+ <slot />
4
+ </ToastTitle>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { type HTMLAttributes, computed } from 'vue'
9
+ import { ToastTitle, type ToastTitleProps } from 'reka-ui'
10
+ import { cn } from '@/utils/tailwind'
11
+
12
+ const props = defineProps<ToastTitleProps & { class?: HTMLAttributes['class'] }>()
13
+
14
+ const delegatedProps = computed(() => {
15
+ const { class: _, ...delegated } = props
16
+
17
+ return delegated
18
+ })
19
+ </script>
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <ToastViewport v-bind="delegatedProps" :class="cn('fixed top-0 z-100 flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]', props.class)" />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { type HTMLAttributes, computed } from 'vue'
7
+ import { ToastViewport, type ToastViewportProps } from 'reka-ui'
8
+ import { cn } from '@/utils/tailwind'
9
+
10
+ const props = defineProps<ToastViewportProps & { class?: HTMLAttributes['class'] }>()
11
+
12
+ const delegatedProps = computed(() => {
13
+ const { class: _, ...delegated } = props
14
+
15
+ return delegated
16
+ })
17
+ </script>
@@ -0,0 +1,30 @@
1
+ <template>
2
+ <ToastProvider>
3
+ <Toast v-for="toast in toasts" :key="toast.id" v-bind="toast">
4
+ <div class="grid gap-1">
5
+ <ToastTitle v-if="toast.title">
6
+ {{ toast.title }}
7
+ </ToastTitle>
8
+ <template v-if="toast.description">
9
+ <ToastDescription v-if="isVNode(toast.description)">
10
+ <component :is="toast.description" />
11
+ </ToastDescription>
12
+ <ToastDescription v-else>
13
+ {{ toast.description }}
14
+ </ToastDescription>
15
+ </template>
16
+ <ToastClose :variant="toast.variant" />
17
+ </div>
18
+ <component :is="toast.action" :variant="toast.variant" />
19
+ </Toast>
20
+ <ToastViewport />
21
+ </ToastProvider>
22
+ </template>
23
+
24
+ <script setup lang="ts">
25
+ import { isVNode } from 'vue'
26
+ import { useToast } from './useToast'
27
+ import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport } from '.'
28
+
29
+ const { toasts } = useToast()
30
+ </script>
@@ -0,0 +1,34 @@
1
+ import type { ToastRootProps } from 'reka-ui'
2
+ import type { HTMLAttributes } from 'vue'
3
+
4
+ export { default as Toaster } from './Toaster.vue'
5
+ export { default as Toast } from './Toast.vue'
6
+ export { default as ToastViewport } from './ToastViewport.vue'
7
+ export { default as ToastAction } from './ToastAction.vue'
8
+ export { default as ToastClose } from './ToastClose.vue'
9
+ export { default as ToastTitle } from './ToastTitle.vue'
10
+ export { default as ToastDescription } from './ToastDescription.vue'
11
+ export { default as ToastProvider } from './ToastProvider.vue'
12
+ export { toast, useToast } from './useToast'
13
+
14
+ import { type VariantProps, cva } from 'class-variance-authority'
15
+
16
+ export const toastVariants = cva('group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-4 pr-10 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--reka-toast-swipe-end-x) data-[swipe=move]:translate-x-(--reka-toast-swipe-move-x) data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full', {
17
+ variants: {
18
+ variant: {
19
+ default: 'border bg-background text-foreground',
20
+ destructive: 'destructive group border-destructive bg-destructive text-destructive-foreground'
21
+ }
22
+ },
23
+ defaultVariants: {
24
+ variant: 'default'
25
+ }
26
+ })
27
+
28
+ export type ToastVariants = VariantProps<typeof toastVariants>
29
+
30
+ export interface ToastProps extends ToastRootProps {
31
+ class?: HTMLAttributes['class']
32
+ variant?: ToastVariants['variant']
33
+ onOpenChange?: ((value: boolean) => void) | undefined
34
+ }
@@ -0,0 +1,163 @@
1
+ import { computed, ref } from 'vue'
2
+ import type { Component, VNode } from 'vue'
3
+ import type { ToastProps } from '.'
4
+
5
+ const TOAST_LIMIT = 1
6
+ const TOAST_REMOVE_DELAY = 1000000
7
+
8
+ export type StringOrVNode =
9
+ | string
10
+ | VNode
11
+ | (() => VNode)
12
+
13
+ type ToasterToast = ToastProps & {
14
+ id: string
15
+ title?: string
16
+ description?: StringOrVNode
17
+ action?: Component
18
+ }
19
+
20
+ const actionTypes = {
21
+ ADD_TOAST: 'ADD_TOAST',
22
+ UPDATE_TOAST: 'UPDATE_TOAST',
23
+ DISMISS_TOAST: 'DISMISS_TOAST',
24
+ REMOVE_TOAST: 'REMOVE_TOAST'
25
+ } as const
26
+
27
+ let count = 0
28
+
29
+ function genId () {
30
+ count = (count + 1) % Number.MAX_VALUE
31
+ return count.toString()
32
+ }
33
+
34
+ type ActionType = typeof actionTypes
35
+
36
+ type Action =
37
+ | {
38
+ type: ActionType['ADD_TOAST']
39
+ toast: ToasterToast
40
+ }
41
+ | {
42
+ type: ActionType['UPDATE_TOAST']
43
+ toast: Partial<ToasterToast>
44
+ }
45
+ | {
46
+ type: ActionType['DISMISS_TOAST']
47
+ toastId?: ToasterToast['id']
48
+ }
49
+ | {
50
+ type: ActionType['REMOVE_TOAST']
51
+ toastId?: ToasterToast['id']
52
+ }
53
+
54
+ interface State {
55
+ toasts: ToasterToast[]
56
+ }
57
+
58
+ const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()
59
+
60
+ function addToRemoveQueue (toastId: string) {
61
+ if (toastTimeouts.has(toastId))
62
+ return
63
+
64
+ const timeout = setTimeout(() => {
65
+ toastTimeouts.delete(toastId)
66
+ dispatch({
67
+ type: actionTypes.REMOVE_TOAST,
68
+ toastId
69
+ })
70
+ }, TOAST_REMOVE_DELAY)
71
+
72
+ toastTimeouts.set(toastId, timeout)
73
+ }
74
+
75
+ const state = ref<State>({
76
+ toasts: []
77
+ })
78
+
79
+ function dispatch (action: Action) {
80
+ switch (action.type) {
81
+ case actionTypes.ADD_TOAST:
82
+ state.value.toasts = [action.toast, ...state.value.toasts].slice(0, TOAST_LIMIT)
83
+ break
84
+
85
+ case actionTypes.UPDATE_TOAST:
86
+ state.value.toasts = state.value.toasts.map(t =>
87
+ t.id === action.toast.id ? { ...t, ...action.toast } : t)
88
+ break
89
+
90
+ case actionTypes.DISMISS_TOAST: {
91
+ const { toastId } = action
92
+
93
+ if (toastId) {
94
+ addToRemoveQueue(toastId)
95
+ } else {
96
+ state.value.toasts.forEach((toast) => {
97
+ addToRemoveQueue(toast.id)
98
+ })
99
+ }
100
+
101
+ state.value.toasts = state.value.toasts.map(t =>
102
+ t.id === toastId || toastId === undefined
103
+ ? {
104
+ ...t,
105
+ open: false
106
+ }
107
+ : t)
108
+ break
109
+ }
110
+
111
+ case actionTypes.REMOVE_TOAST:
112
+ if (action.toastId === undefined)
113
+ state.value.toasts = []
114
+ else
115
+ state.value.toasts = state.value.toasts.filter(t => t.id !== action.toastId)
116
+
117
+ break
118
+ }
119
+ }
120
+
121
+ function useToast () {
122
+ return {
123
+ toasts: computed(() => state.value.toasts),
124
+ toast,
125
+ dismiss: (toastId?: string) => dispatch({ type: actionTypes.DISMISS_TOAST, toastId })
126
+ }
127
+ }
128
+
129
+ type Toast = Omit<ToasterToast, 'id'>
130
+
131
+ function toast (payload: Toast | string) {
132
+ const props = typeof payload === 'string' ? { description: payload } : payload
133
+ const id = genId()
134
+
135
+ const update = (props: ToasterToast) =>
136
+ dispatch({
137
+ type: actionTypes.UPDATE_TOAST,
138
+ toast: { ...props, id }
139
+ })
140
+
141
+ const dismiss = () => dispatch({ type: actionTypes.DISMISS_TOAST, toastId: id })
142
+
143
+ dispatch({
144
+ type: actionTypes.ADD_TOAST,
145
+ toast: {
146
+ ...props,
147
+ id,
148
+ open: true,
149
+ onOpenChange: (open: boolean) => {
150
+ if (!open)
151
+ dismiss()
152
+ }
153
+ }
154
+ })
155
+
156
+ return {
157
+ id,
158
+ dismiss,
159
+ update
160
+ }
161
+ }
162
+
163
+ export { toast, useToast }
@@ -0,0 +1,51 @@
1
+ <template>
2
+ <Tooltip :disabled="!icon || !label">
3
+ <template #trigger>
4
+ <Toggle
5
+ v-bind="forwarded"
6
+ :aria-label="label"
7
+ :data-active="modelValue"
8
+ :class="cn(toggleVariants({ variant, size, icon: Boolean(icon) }), 'data-[active=true]:bg-accent data-[active=true]:text-accent-foreground', props.class)"
9
+ >
10
+ <slot>
11
+ <component
12
+ :is="typeof icon === 'string' ? Icon : icon"
13
+ v-if="icon"
14
+ :class="buttonIconVariants({ size })"
15
+ :icon="icon!"
16
+ />
17
+ </slot>
18
+ </Toggle>
19
+ </template>
20
+
21
+ {{ label }}
22
+ </Tooltip>
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ import { type HTMLAttributes, type Component } from 'vue'
27
+ import { Toggle, type ToggleEmits, type ToggleProps, useForwardPropsEmits } from 'reka-ui'
28
+ import { type ToggleVariants, toggleVariants } from '.'
29
+ import { cn } from '@/utils/tailwind'
30
+ import { Icon } from '@/components/ui/icon'
31
+ import { Tooltip } from '@/components/ui/tooltip'
32
+ import { buttonIconVariants } from '@/components/ui/button'
33
+ import { useDelegatedProps } from '@/composables/delegated-props'
34
+
35
+ const props = withDefaults(defineProps<ToggleProps & {
36
+ class?: HTMLAttributes['class']
37
+ variant?: ToggleVariants['variant']
38
+ size?: ToggleVariants['size']
39
+ icon?: string | Component
40
+ label?: string
41
+ }>(), {
42
+ variant: 'default',
43
+ size: 'md',
44
+ disabled: false
45
+ })
46
+
47
+ const emits = defineEmits<ToggleEmits>()
48
+
49
+ const delegatedProps = useDelegatedProps(props, ['class', 'size', 'variant', 'icon', 'label'])
50
+ const forwarded = useForwardPropsEmits(delegatedProps, emits)
51
+ </script>
@@ -0,0 +1,71 @@
1
+ import { type VariantProps, cva } from 'class-variance-authority'
2
+
3
+ export { default as Toggle } from './Toggle.vue'
4
+
5
+ export const toggleVariants = cva('inline-flex items-center justify-center rounded-md text-xs font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', {
6
+ variants: {
7
+ variant: {
8
+ default: 'bg-transparent',
9
+ outline: 'border border-input bg-transparent hover:bg-accent hover:text-accent-foreground'
10
+ },
11
+ size: {
12
+ '2xs': 'px-2 h-5 rounded-sm font-normal text-2xs',
13
+ xs: 'px-3 h-6 rounded-sm font-normal',
14
+ sm: 'px-3 h-7 rounded-sm font-normal',
15
+ md: 'px-3 h-8',
16
+ lg: 'px-4 h-9 text-sm gap-2'
17
+ },
18
+ icon: {
19
+ true: '',
20
+ false: ''
21
+ }
22
+ },
23
+ compoundVariants: [
24
+ {
25
+ icon: true,
26
+ size: '2xs',
27
+ class: 'px-0 w-5'
28
+ },
29
+ {
30
+ icon: true,
31
+ size: 'xs',
32
+ class: 'px-0 w-6'
33
+ },
34
+ {
35
+ icon: true,
36
+ size: 'sm',
37
+ class: 'px-0 w-7'
38
+ },
39
+ {
40
+ icon: true,
41
+ size: 'md',
42
+ class: 'px-0 w-8'
43
+ },
44
+ {
45
+ icon: true,
46
+ size: 'lg',
47
+ class: 'px-0 w-9'
48
+ }
49
+ ],
50
+ defaultVariants: {
51
+ variant: 'default',
52
+ size: 'md'
53
+ }
54
+ })
55
+
56
+ export const toggleIconVariants = cva('', {
57
+ variants: {
58
+ size: {
59
+ '2xs': 'w-3 h-3',
60
+ xs: 'w-3 h-3',
61
+ sm: 'w-3 h-3',
62
+ md: 'w-4 h-4',
63
+ lg: 'w-5 h-5'
64
+ }
65
+ },
66
+ defaultVariants: {
67
+ size: 'md'
68
+ }
69
+ })
70
+
71
+ export type ToggleVariants = VariantProps<typeof toggleVariants>
@@ -0,0 +1,58 @@
1
+ <template>
2
+ <ToggleGroupRoot
3
+ v-bind="forwarded"
4
+ :class="cn('flex items-center justify-center gap-1', props.class)"
5
+ >
6
+ <ToggleGroupItem
7
+ v-for="item in items"
8
+ :key="item.value"
9
+ :label="item.label"
10
+ :icon="item.icon"
11
+ :size="size"
12
+ :variant="variant"
13
+ :value="item.value"
14
+ >
15
+ <slot v-if="$slots.default || !item.icon" v-bind="{ item }">
16
+ {{ item.label }}
17
+ </slot>
18
+ </ToggleGroupItem>
19
+ </ToggleGroupRoot>
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ import type { VariantProps } from 'class-variance-authority'
24
+ import { type HTMLAttributes } from 'vue'
25
+ import {
26
+ ToggleGroupRoot,
27
+ type ToggleGroupRootEmits,
28
+ type ToggleGroupRootProps,
29
+ useForwardPropsEmits
30
+ } from 'reka-ui'
31
+ import type { toggleVariants } from '@/components/ui/toggle'
32
+ import ToggleGroupItem from './ToggleGroupItem.vue'
33
+ import { cn } from '@/utils/tailwind'
34
+ import { useDelegatedProps } from '@/composables/delegated-props'
35
+
36
+ type ToggleGroupVariants = VariantProps<typeof toggleVariants>
37
+
38
+ interface Item {
39
+ label: string
40
+ value: number | string
41
+ icon?: string
42
+ }
43
+
44
+ const emits = defineEmits<ToggleGroupRootEmits>()
45
+ const props = defineProps<ToggleGroupRootProps & {
46
+ class?: HTMLAttributes['class']
47
+ variant?: ToggleGroupVariants['variant']
48
+ size?: ToggleGroupVariants['size'],
49
+ items: Item[]
50
+ }>()
51
+
52
+ defineSlots<{
53
+ default(props: { item: Item }): any
54
+ }>()
55
+
56
+ const delegatedProps = useDelegatedProps(props, ['class', 'size', 'variant', 'items'])
57
+ const forwarded = useForwardPropsEmits(delegatedProps, emits)
58
+ </script>
@@ -0,0 +1,54 @@
1
+ <template>
2
+ <Tooltip :disabled="!label || !icon">
3
+ <template #trigger>
4
+ <ToggleGroupItem
5
+ v-bind="forwardedProps"
6
+ :aria-label="label"
7
+ :class="cn(toggleVariants({
8
+ variant: variant,
9
+ size: size,
10
+ icon: Boolean(icon)
11
+ }), 'data-active:bg-accent data-active:text-accent-foreground', props.class)"
12
+ >
13
+ <slot>
14
+ <component
15
+ :is="typeof icon === 'string' ? Icon : icon"
16
+ v-if="icon"
17
+ :class="buttonIconVariants({ size })"
18
+ :icon="icon!"
19
+ />
20
+ </slot>
21
+ </ToggleGroupItem>
22
+ </template>
23
+
24
+ {{ label }}
25
+ </Tooltip>
26
+ </template>
27
+
28
+ <script setup lang="ts">
29
+ import type { VariantProps } from 'class-variance-authority'
30
+ import { type HTMLAttributes, type Component, computed } from 'vue'
31
+ import { ToggleGroupItem, type ToggleGroupItemProps, useForwardProps } from 'reka-ui'
32
+ import { toggleVariants } from '@/components/ui/toggle'
33
+ import { cn } from '@/utils/tailwind'
34
+ import { buttonIconVariants } from '@/components/ui/button'
35
+ import { Tooltip } from '@/components/ui/tooltip'
36
+ import { Icon } from '@/components/ui/icon'
37
+
38
+ type ToggleGroupVariants = VariantProps<typeof toggleVariants>
39
+
40
+ const props = defineProps<ToggleGroupItemProps & {
41
+ class?: HTMLAttributes['class']
42
+ variant?: ToggleGroupVariants['variant']
43
+ label?: string
44
+ size?: ToggleGroupVariants['size']
45
+ icon?: string | Component
46
+ }>()
47
+
48
+ const delegatedProps = computed(() => {
49
+ const { class: _, variant: _variant, size: _size, ...delegated } = props
50
+ return delegated
51
+ })
52
+
53
+ const forwardedProps = useForwardProps(delegatedProps)
54
+ </script>
@@ -0,0 +1 @@
1
+ export { default as ToggleGroup } from './ToggleGroup.vue'
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <TooltipRoot v-bind="forwarded">
3
+ <TooltipTrigger as-child>
4
+ <slot name="trigger" />
5
+ </TooltipTrigger>
6
+ <TooltipPortal :to="options.portalTo">
7
+ <TooltipContent
8
+ v-bind="$attrs"
9
+ :side-offset="4"
10
+ align="center"
11
+ :class="cn('z-50 overflow-hidden rounded-md border bg-popover px-2 py-1 text-xs text-popover-foreground shadow-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', props.class)"
12
+ >
13
+ <slot />
14
+ </TooltipContent>
15
+ </TooltipPortal>
16
+ </TooltipRoot>
17
+ </template>
18
+
19
+ <script setup lang="ts">
20
+ import {
21
+ TooltipPortal,
22
+ TooltipRoot,
23
+ TooltipContent,
24
+ TooltipTrigger,
25
+ type TooltipRootEmits,
26
+ type TooltipRootProps,
27
+ useForwardPropsEmits
28
+ } from 'reka-ui'
29
+ import { cn } from '@/utils/tailwind'
30
+ import type { HTMLAttributes } from 'vue'
31
+ import { useDelegatedProps } from '@/composables/delegated-props'
32
+ import { getOptions } from '@/options-provider'
33
+
34
+ const props = defineProps<TooltipRootProps & {
35
+ class?: HTMLAttributes['class']
36
+ }>()
37
+ const emits = defineEmits<TooltipRootEmits>()
38
+
39
+ const delegatedProps = useDelegatedProps(props, ['class'])
40
+ const forwarded = useForwardPropsEmits(delegatedProps, emits)
41
+ const options = getOptions()
42
+ </script>
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <TooltipProvider v-bind="props">
3
+ <slot />
4
+ </TooltipProvider>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { TooltipProvider, type TooltipProviderProps } from 'reka-ui'
9
+
10
+ const props = defineProps<TooltipProviderProps>()
11
+ </script>
@@ -0,0 +1,2 @@
1
+ export { default as Tooltip } from './Tooltip.vue'
2
+ export { default as TooltipProvider } from './TooltipProvider.vue'