@byyuurin/ui 0.0.9 → 0.0.11

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 (215) hide show
  1. package/README.md +2 -5
  2. package/dist/module.json +3 -3
  3. package/dist/module.mjs +1 -1
  4. package/dist/module.mjs.map +1 -1
  5. package/dist/runtime/app/injections.d.ts +9323 -3
  6. package/dist/runtime/app/injections.js +35 -0
  7. package/dist/runtime/components/Accordion.vue +36 -69
  8. package/dist/runtime/components/Accordion.vue.d.ts +52 -0
  9. package/dist/runtime/components/Alert.vue +37 -75
  10. package/dist/runtime/components/Alert.vue.d.ts +59 -0
  11. package/dist/runtime/components/App.vue +25 -40
  12. package/dist/runtime/components/App.vue.d.ts +24 -0
  13. package/dist/runtime/components/Avatar.vue +31 -51
  14. package/dist/runtime/components/Avatar.vue.d.ts +25 -0
  15. package/dist/runtime/components/AvatarGroup.vue +38 -69
  16. package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
  17. package/dist/runtime/components/Badge.vue +25 -51
  18. package/dist/runtime/components/Badge.vue.d.ts +44 -0
  19. package/dist/runtime/components/Breadcrumb.vue +35 -77
  20. package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
  21. package/dist/runtime/components/Button.vue +62 -51
  22. package/dist/runtime/components/Button.vue.d.ts +29 -0
  23. package/dist/runtime/components/ButtonGroup.vue +17 -37
  24. package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
  25. package/dist/runtime/components/Calendar.vue +75 -101
  26. package/dist/runtime/components/Calendar.vue.d.ts +75 -0
  27. package/dist/runtime/components/Card.vue +25 -42
  28. package/dist/runtime/components/Card.vue.d.ts +30 -0
  29. package/dist/runtime/components/Carousel.vue +118 -223
  30. package/dist/runtime/components/Carousel.vue.d.ts +104 -0
  31. package/dist/runtime/components/Checkbox.vue +49 -71
  32. package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
  33. package/dist/runtime/components/Chip.vue +31 -48
  34. package/dist/runtime/components/Chip.vue.d.ts +30 -0
  35. package/dist/runtime/components/Collapsible.vue +22 -30
  36. package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
  37. package/dist/runtime/components/Drawer.vue +52 -102
  38. package/dist/runtime/components/Drawer.vue.d.ts +80 -0
  39. package/dist/runtime/components/DropdownMenu.vue +65 -0
  40. package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
  41. package/dist/runtime/components/DropdownMenuContent.vue +192 -0
  42. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
  43. package/dist/runtime/components/Form.vue +197 -0
  44. package/dist/runtime/components/Form.vue.d.ts +78 -0
  45. package/dist/runtime/components/FormItem.vue +90 -0
  46. package/dist/runtime/components/FormItem.vue.d.ts +60 -0
  47. package/dist/runtime/components/Input.vue +93 -115
  48. package/dist/runtime/components/Input.vue.d.ts +64 -0
  49. package/dist/runtime/components/InputNumber.vue +81 -116
  50. package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
  51. package/dist/runtime/components/Kbd.vue +18 -39
  52. package/dist/runtime/components/Kbd.vue.d.ts +28 -0
  53. package/dist/runtime/components/Link.vue +170 -244
  54. package/dist/runtime/components/Link.vue.d.ts +95 -0
  55. package/dist/runtime/components/LinkBase.vue +36 -54
  56. package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
  57. package/dist/runtime/components/Modal.vue +50 -85
  58. package/dist/runtime/components/Modal.vue.d.ts +66 -0
  59. package/dist/runtime/components/OverlayProvider.vue +10 -14
  60. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  61. package/dist/runtime/components/Pagination.vue +55 -121
  62. package/dist/runtime/components/Pagination.vue.d.ts +93 -0
  63. package/dist/runtime/components/PinInput.vue +57 -57
  64. package/dist/runtime/components/PinInput.vue.d.ts +35 -0
  65. package/dist/runtime/components/Popover.vue +39 -68
  66. package/dist/runtime/components/Popover.vue.d.ts +45 -0
  67. package/dist/runtime/components/Progress.vue +68 -120
  68. package/dist/runtime/components/Progress.vue.d.ts +54 -0
  69. package/dist/runtime/components/RadioGroup.vue +75 -129
  70. package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
  71. package/dist/runtime/components/ScrollArea.vue +31 -31
  72. package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
  73. package/dist/runtime/components/Select.vue +119 -199
  74. package/dist/runtime/components/Select.vue.d.ts +119 -0
  75. package/dist/runtime/components/Separator.vue +26 -44
  76. package/dist/runtime/components/Separator.vue.d.ts +27 -0
  77. package/dist/runtime/components/Skeleton.vue +12 -21
  78. package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
  79. package/dist/runtime/components/Slider.vue +54 -71
  80. package/dist/runtime/components/Slider.vue.d.ts +36 -0
  81. package/dist/runtime/components/Switch.vue +54 -68
  82. package/dist/runtime/components/Switch.vue.d.ts +49 -0
  83. package/dist/runtime/components/Table.vue +113 -186
  84. package/dist/runtime/components/Table.vue.d.ts +148 -0
  85. package/dist/runtime/components/Tabs.vue +35 -79
  86. package/dist/runtime/components/Tabs.vue.d.ts +65 -0
  87. package/dist/runtime/components/Textarea.vue +82 -123
  88. package/dist/runtime/components/Textarea.vue.d.ts +60 -0
  89. package/dist/runtime/components/Toast.vue +51 -76
  90. package/dist/runtime/components/Toast.vue.d.ts +131 -0
  91. package/dist/runtime/components/ToastProvider.vue +65 -101
  92. package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
  93. package/dist/runtime/components/Tooltip.vue +36 -47
  94. package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
  95. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  96. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  97. package/dist/runtime/composables/useFormItem.d.ts +27 -0
  98. package/dist/runtime/composables/useFormItem.js +64 -0
  99. package/dist/runtime/composables/useKbd.d.ts +1 -1
  100. package/dist/runtime/composables/useLocale.d.ts +3 -3
  101. package/dist/runtime/composables/useTheme.d.ts +1 -1
  102. package/dist/runtime/composables/useTheme.js +2 -1
  103. package/dist/runtime/composables/useToast.d.ts +1 -1
  104. package/dist/runtime/index.d.ts +3 -0
  105. package/dist/runtime/index.js +3 -0
  106. package/dist/runtime/locale/en.d.ts +1 -1
  107. package/dist/runtime/locale/zh-tw.d.ts +1 -1
  108. package/dist/runtime/theme/accordion.d.ts +45 -51
  109. package/dist/runtime/theme/accordion.js +1 -1
  110. package/dist/runtime/theme/alert.d.ts +115 -121
  111. package/dist/runtime/theme/alert.js +1 -1
  112. package/dist/runtime/theme/app.d.ts +1 -0
  113. package/dist/runtime/theme/app.js +2 -1
  114. package/dist/runtime/theme/avatar-group.d.ts +42 -48
  115. package/dist/runtime/theme/avatar-group.js +1 -1
  116. package/dist/runtime/theme/avatar.d.ts +46 -52
  117. package/dist/runtime/theme/avatar.js +1 -1
  118. package/dist/runtime/theme/badge.d.ts +63 -93
  119. package/dist/runtime/theme/badge.js +1 -1
  120. package/dist/runtime/theme/breadcrumb.d.ts +52 -58
  121. package/dist/runtime/theme/breadcrumb.js +1 -1
  122. package/dist/runtime/theme/button-group.d.ts +36 -42
  123. package/dist/runtime/theme/button.d.ts +165 -117
  124. package/dist/runtime/theme/button.js +1 -1
  125. package/dist/runtime/theme/calendar.d.ts +52 -50
  126. package/dist/runtime/theme/calendar.js +20 -3
  127. package/dist/runtime/theme/card.d.ts +52 -58
  128. package/dist/runtime/theme/card.js +1 -1
  129. package/dist/runtime/theme/carousel.d.ts +98 -104
  130. package/dist/runtime/theme/carousel.js +1 -1
  131. package/dist/runtime/theme/checkbox.d.ts +77 -83
  132. package/dist/runtime/theme/checkbox.js +1 -1
  133. package/dist/runtime/theme/chip.d.ts +50 -89
  134. package/dist/runtime/theme/chip.js +1 -1
  135. package/dist/runtime/theme/collapsible.d.ts +29 -35
  136. package/dist/runtime/theme/collapsible.js +1 -1
  137. package/dist/runtime/theme/drawer.d.ts +131 -102
  138. package/dist/runtime/theme/drawer.js +1 -1
  139. package/dist/runtime/theme/dropdown-menu.d.ts +65 -0
  140. package/dist/runtime/theme/dropdown-menu.js +83 -0
  141. package/dist/runtime/theme/form-item.d.ts +70 -0
  142. package/dist/runtime/theme/form-item.js +34 -0
  143. package/dist/runtime/theme/form.d.ts +2 -0
  144. package/dist/runtime/theme/form.js +7 -0
  145. package/dist/runtime/theme/index.d.ts +3 -0
  146. package/dist/runtime/theme/index.js +3 -0
  147. package/dist/runtime/theme/input-number.d.ts +100 -126
  148. package/dist/runtime/theme/input-number.js +1 -1
  149. package/dist/runtime/theme/input.d.ts +153 -131
  150. package/dist/runtime/theme/input.js +3 -3
  151. package/dist/runtime/theme/kbd.d.ts +30 -36
  152. package/dist/runtime/theme/link.d.ts +37 -43
  153. package/dist/runtime/theme/modal.d.ts +35 -69
  154. package/dist/runtime/theme/modal.js +1 -1
  155. package/dist/runtime/theme/pagination.d.ts +71 -77
  156. package/dist/runtime/theme/pagination.js +1 -1
  157. package/dist/runtime/theme/pinInput.d.ts +82 -88
  158. package/dist/runtime/theme/pinInput.js +2 -2
  159. package/dist/runtime/theme/popover.d.ts +29 -35
  160. package/dist/runtime/theme/popover.js +1 -1
  161. package/dist/runtime/theme/progress.d.ts +167 -109
  162. package/dist/runtime/theme/progress.js +1 -1
  163. package/dist/runtime/theme/radio-group.d.ts +99 -105
  164. package/dist/runtime/theme/radio-group.js +1 -1
  165. package/dist/runtime/theme/scroll-area.d.ts +62 -68
  166. package/dist/runtime/theme/scroll-area.js +1 -1
  167. package/dist/runtime/theme/select.d.ts +168 -158
  168. package/dist/runtime/theme/select.js +3 -2
  169. package/dist/runtime/theme/separator.d.ts +64 -85
  170. package/dist/runtime/theme/separator.js +1 -1
  171. package/dist/runtime/theme/skeleton.d.ts +1 -7
  172. package/dist/runtime/theme/slider.d.ts +62 -68
  173. package/dist/runtime/theme/slider.js +1 -1
  174. package/dist/runtime/theme/switch.d.ts +111 -117
  175. package/dist/runtime/theme/switch.js +1 -1
  176. package/dist/runtime/theme/table.d.ts +75 -78
  177. package/dist/runtime/theme/table.js +3 -2
  178. package/dist/runtime/theme/tabs.d.ts +116 -139
  179. package/dist/runtime/theme/tabs.js +1 -1
  180. package/dist/runtime/theme/textarea.d.ts +78 -90
  181. package/dist/runtime/theme/textarea.js +2 -2
  182. package/dist/runtime/theme/toast-provider.d.ts +110 -131
  183. package/dist/runtime/theme/toast-provider.js +1 -1
  184. package/dist/runtime/theme/toast.d.ts +74 -80
  185. package/dist/runtime/theme/toast.js +1 -1
  186. package/dist/runtime/theme/tooltip.d.ts +35 -41
  187. package/dist/runtime/theme/tooltip.js +1 -1
  188. package/dist/runtime/types/components.d.ts +3 -0
  189. package/dist/runtime/types/form.d.ts +45 -0
  190. package/dist/runtime/types/form.js +0 -0
  191. package/dist/runtime/types/index.d.ts +5 -2
  192. package/dist/runtime/types/index.js +1 -0
  193. package/dist/runtime/types/utils.d.ts +37 -16
  194. package/dist/runtime/utils/extend-theme.js +15 -4
  195. package/dist/runtime/utils/form.d.ts +5 -0
  196. package/dist/runtime/utils/form.js +24 -0
  197. package/dist/runtime/utils/index.d.ts +2 -0
  198. package/dist/runtime/utils/index.js +4 -0
  199. package/dist/runtime/utils/link.d.ts +4 -28
  200. package/dist/runtime/utils/link.js +10 -3
  201. package/dist/runtime/utils/styler.d.ts +2 -2
  202. package/dist/runtime/utils/styler.js +2 -2
  203. package/dist/shared/ui.D1BTWZFB.mjs +5 -0
  204. package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
  205. package/dist/types.d.mts +1 -1
  206. package/dist/unocss.mjs +7 -6
  207. package/dist/unocss.mjs.map +1 -1
  208. package/dist/unplugin.mjs +1 -1
  209. package/dist/unplugin.mjs.map +1 -1
  210. package/dist/vite.mjs +1 -1
  211. package/package.json +78 -74
  212. package/dist/module.cjs +0 -5
  213. package/dist/shared/ui.1a1f119c.mjs +0 -5
  214. package/dist/shared/ui.1a1f119c.mjs.map +0 -1
  215. package/dist/types.d.ts +0 -1
@@ -1,75 +1,44 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { PrimitiveProps, ToastRootEmits, ToastRootProps } from 'reka-ui'
4
- import type { toast } from '../theme'
5
- import type { ButtonProps, ComponentAttrs } from '../types'
1
+ <script>
6
2
 
7
- export interface ToastEmits extends ToastRootEmits {}
8
-
9
- export interface ToastSlots {
10
- icon?: (props?: {}) => any
11
- title?: (props?: {}) => any
12
- description?: (props?: {}) => any
13
- actions?: (props?: {}) => any
14
- close?: (props: { ui: any }) => any
15
- }
16
-
17
- type ToastVariants = VariantProps<typeof toast>
18
-
19
- export interface ToastProps extends ComponentAttrs<typeof toast>, Pick<ToastRootProps, 'defaultOpen' | 'open' | 'type' | 'duration'> {
20
- /** @default "li" */
21
- as?: PrimitiveProps['as']
22
- title?: string
23
- description?: string
24
- icon?: string
25
- orientation?: ToastVariants['orientation']
26
- /**
27
- * Display a list of actions:
28
- * - under the title and description when orientation is `vertical`
29
- * - next to the close button when orientation is `horizontal`
30
- */
31
- actions?: ButtonProps[]
32
- /**
33
- * Display a close button to dismiss the toast.
34
- * @default true
35
- */
36
- close?: ButtonProps | boolean
37
- /** @default app.icons.close */
38
- closeIcon?: string
39
- }
40
3
  </script>
41
4
 
42
- <script setup lang="ts">
43
- import { reactivePick, useElementBounding } from '@vueuse/core'
44
- import { ToastAction, ToastClose, ToastDescription, ToastRoot, ToastTitle, useForwardPropsEmits } from 'reka-ui'
45
- import { computed, ref } from 'vue'
46
- import { useLocale } from '../composables/useLocale'
47
- import { useTheme } from '../composables/useTheme'
48
- import Button from './Button.vue'
49
-
50
- const props = withDefaults(defineProps<ToastProps>(), {
51
- orientation: 'vertical',
52
- close: true,
53
- })
54
-
55
- const emit = defineEmits<ToastEmits>()
56
- const slots = defineSlots<ToastSlots>()
57
-
58
- const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultOpen', 'open', 'duration', 'type'), emit)
59
-
60
- const el = ref<InstanceType<typeof ToastRoot>>()
61
- const { height } = useElementBounding(() => el.value?.$el.getBoundingClientRect ? el.value.$el : undefined)
62
-
63
- const { t } = useLocale()
64
- const { theme, generateStyle } = useTheme()
65
- const style = computed(() => generateStyle('toast', {
5
+ <script setup>
6
+ import { reactivePick, useElementBounding } from "@vueuse/core";
7
+ import { ToastAction, ToastClose, ToastDescription, ToastRoot, ToastTitle, useForwardPropsEmits } from "reka-ui";
8
+ import { computed, ref } from "vue";
9
+ import { useLocale } from "../composables/useLocale";
10
+ import { useTheme } from "../composables/useTheme";
11
+ import Button from "./Button.vue";
12
+ const props = defineProps({
13
+ as: { type: null, required: false },
14
+ title: { type: String, required: false },
15
+ description: { type: String, required: false },
16
+ icon: { type: String, required: false },
17
+ orientation: { type: null, required: false, default: "vertical" },
18
+ actions: { type: Array, required: false },
19
+ close: { type: [Object, Boolean], required: false, default: true },
20
+ closeIcon: { type: String, required: false },
21
+ class: { type: null, required: false },
22
+ ui: { type: null, required: false },
23
+ defaultOpen: { type: Boolean, required: false },
24
+ open: { type: Boolean, required: false },
25
+ type: { type: String, required: false },
26
+ duration: { type: Number, required: false }
27
+ });
28
+ const emit = defineEmits(["escapeKeyDown", "pause", "resume", "swipeStart", "swipeMove", "swipeCancel", "swipeEnd", "update:open"]);
29
+ const slots = defineSlots();
30
+ const rootProps = useForwardPropsEmits(reactivePick(props, "as", "defaultOpen", "open", "duration", "type"), emit);
31
+ const el = ref();
32
+ const { height } = useElementBounding(() => el.value?.$el.getBoundingClientRect ? el.value.$el : void 0);
33
+ const { t } = useLocale();
34
+ const { theme, generateStyle } = useTheme();
35
+ const style = computed(() => generateStyle("toast", {
66
36
  ...props,
67
- title: !!(props.title || slots.title),
68
- }))
69
-
37
+ title: !!(props.title || slots.title)
38
+ }));
70
39
  defineExpose({
71
- height,
72
- })
40
+ height
41
+ });
73
42
  </script>
74
43
 
75
44
  <template>
@@ -78,25 +47,26 @@ defineExpose({
78
47
  v-slot="{ remaining, duration }"
79
48
  v-bind="rootProps"
80
49
  :class="style.root({ class: [props.class, props.ui?.root] })"
50
+ data-part="root"
81
51
  :style="{ '--height': height }"
82
52
  >
83
53
  <slot name="icon">
84
- <span v-if="props.icon" :class="style.icon({ class: [props.icon, props.ui?.icon] })"></span>
54
+ <span v-if="props.icon" :class="style.icon({ class: [props.icon, props.ui?.icon] })" data-part="icon"></span>
85
55
  </slot>
86
56
 
87
- <div :class="style.wrapper({ class: props.ui?.wrapper })">
88
- <ToastTitle v-if="props.title || !!slots.title" :class="style.title({ class: props.ui?.title })">
57
+ <div :class="style.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
58
+ <ToastTitle v-if="props.title || !!slots.title" :class="style.title({ class: props.ui?.title })" data-part="title">
89
59
  <slot name="title">
90
60
  {{ props.title }}
91
61
  </slot>
92
62
  </ToastTitle>
93
- <ToastDescription v-if="props.description || !!slots.description" :class="style.description({ class: props.ui?.description })">
63
+ <ToastDescription v-if="props.description || !!slots.description" :class="style.description({ class: props.ui?.description })" data-part="description">
94
64
  <slot name="description">
95
65
  {{ props.description }}
96
66
  </slot>
97
67
  </ToastDescription>
98
68
 
99
- <div v-if="props.orientation === 'vertical' && actions?.length" :class="style.actions({ class: props.ui?.actions })">
69
+ <div v-if="props.orientation === 'vertical' && actions?.length" :class="style.actions({ class: props.ui?.actions })" data-part="actions">
100
70
  <slot name="actions">
101
71
  <ToastAction v-for="(action, index) in props.actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
102
72
  <Button size="xs" v-bind="action" />
@@ -105,7 +75,11 @@ defineExpose({
105
75
  </div>
106
76
  </div>
107
77
 
108
- <div v-if="(props.orientation === 'horizontal' && actions?.length) || props.close || slots.close" :class="style.actions({ class: props.ui?.actions })">
78
+ <div
79
+ v-if="props.orientation === 'horizontal' && actions?.length || props.close || slots.close"
80
+ :class="style.actions({ class: props.ui?.actions })"
81
+ data-part="actions"
82
+ >
109
83
  <template v-if="props.orientation === 'horizontal'">
110
84
  <slot name="actions">
111
85
  <ToastAction v-for="(action, index) in props.actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
@@ -115,20 +89,21 @@ defineExpose({
115
89
  </template>
116
90
 
117
91
  <ToastClose v-if="props.close || slots.close" as-child>
118
- <slot name="close" :ui="ui">
92
+ <slot name="close" :ui="props.ui">
119
93
  <Button
120
94
  :icon="props.closeIcon || theme.app.icons.close"
121
95
  size="sm"
122
96
  variant="link"
123
97
  :aria-label="t('toast.close')"
124
- v-bind="typeof close === 'object' ? close : undefined"
98
+ v-bind="typeof close === 'object' ? close : void 0"
125
99
  :class="style.close({ class: props.ui?.close })"
100
+ data-part="close"
126
101
  @click.stop
127
102
  />
128
103
  </slot>
129
104
  </ToastClose>
130
105
  </div>
131
106
 
132
- <div v-if="remaining >= 0 && duration" :class="style.progress({ class: props.ui?.progress })" :style="{ width: `${remaining / duration * 100}%` }"></div>
107
+ <div v-if="remaining >= 0 && duration" :class="style.progress({ class: props.ui?.progress })" data-part="progress" :style="{ width: `${remaining / duration * 100}%` }"></div>
133
108
  </ToastRoot>
134
109
  </template>
@@ -0,0 +1,131 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { PrimitiveProps, ToastRootEmits, ToastRootProps } from 'reka-ui';
3
+ import type { toast } from '../theme/index.js';
4
+ import type { ButtonProps, ComponentAttrs } from '../types/index.js';
5
+ export interface ToastEmits extends ToastRootEmits {
6
+ }
7
+ export interface ToastSlots {
8
+ icon?: (props?: {}) => any;
9
+ title?: (props?: {}) => any;
10
+ description?: (props?: {}) => any;
11
+ actions?: (props?: {}) => any;
12
+ close?: (props: {
13
+ ui: ComponentAttrs<typeof toast>['ui'];
14
+ }) => any;
15
+ }
16
+ type ToastVariants = VariantProps<typeof toast>;
17
+ export interface ToastProps extends ComponentAttrs<typeof toast>, Pick<ToastRootProps, 'defaultOpen' | 'open' | 'type' | 'duration'> {
18
+ /** @default "li" */
19
+ as?: PrimitiveProps['as'];
20
+ title?: string;
21
+ description?: string;
22
+ icon?: string;
23
+ orientation?: ToastVariants['orientation'];
24
+ /**
25
+ * Display a list of actions:
26
+ * - under the title and description when orientation is `vertical`
27
+ * - next to the close button when orientation is `horizontal`
28
+ */
29
+ actions?: ButtonProps[];
30
+ /**
31
+ * Display a close button to dismiss the toast.
32
+ * @default true
33
+ */
34
+ close?: ButtonProps | boolean;
35
+ /** @default app.icons.close */
36
+ closeIcon?: string;
37
+ }
38
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<ToastProps, {
39
+ height: import("vue").ShallowRef<number, number>;
40
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
41
+ "update:open": (value: boolean) => any;
42
+ escapeKeyDown: (event: KeyboardEvent) => any;
43
+ pause: () => any;
44
+ resume: () => any;
45
+ swipeStart: (event: {
46
+ currentTarget: EventTarget & HTMLElement;
47
+ } & Omit<CustomEvent<{
48
+ originalEvent: PointerEvent;
49
+ delta: {
50
+ x: number;
51
+ y: number;
52
+ };
53
+ }>, "currentTarget">) => any;
54
+ swipeMove: (event: {
55
+ currentTarget: EventTarget & HTMLElement;
56
+ } & Omit<CustomEvent<{
57
+ originalEvent: PointerEvent;
58
+ delta: {
59
+ x: number;
60
+ y: number;
61
+ };
62
+ }>, "currentTarget">) => any;
63
+ swipeCancel: (event: {
64
+ currentTarget: EventTarget & HTMLElement;
65
+ } & Omit<CustomEvent<{
66
+ originalEvent: PointerEvent;
67
+ delta: {
68
+ x: number;
69
+ y: number;
70
+ };
71
+ }>, "currentTarget">) => any;
72
+ swipeEnd: (event: {
73
+ currentTarget: EventTarget & HTMLElement;
74
+ } & Omit<CustomEvent<{
75
+ originalEvent: PointerEvent;
76
+ delta: {
77
+ x: number;
78
+ y: number;
79
+ };
80
+ }>, "currentTarget">) => any;
81
+ }, string, import("vue").PublicProps, Readonly<ToastProps> & Readonly<{
82
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
83
+ onEscapeKeyDown?: ((event: KeyboardEvent) => any) | undefined;
84
+ onPause?: (() => any) | undefined;
85
+ onResume?: (() => any) | undefined;
86
+ onSwipeStart?: ((event: {
87
+ currentTarget: EventTarget & HTMLElement;
88
+ } & Omit<CustomEvent<{
89
+ originalEvent: PointerEvent;
90
+ delta: {
91
+ x: number;
92
+ y: number;
93
+ };
94
+ }>, "currentTarget">) => any) | undefined;
95
+ onSwipeMove?: ((event: {
96
+ currentTarget: EventTarget & HTMLElement;
97
+ } & Omit<CustomEvent<{
98
+ originalEvent: PointerEvent;
99
+ delta: {
100
+ x: number;
101
+ y: number;
102
+ };
103
+ }>, "currentTarget">) => any) | undefined;
104
+ onSwipeCancel?: ((event: {
105
+ currentTarget: EventTarget & HTMLElement;
106
+ } & Omit<CustomEvent<{
107
+ originalEvent: PointerEvent;
108
+ delta: {
109
+ x: number;
110
+ y: number;
111
+ };
112
+ }>, "currentTarget">) => any) | undefined;
113
+ onSwipeEnd?: ((event: {
114
+ currentTarget: EventTarget & HTMLElement;
115
+ } & Omit<CustomEvent<{
116
+ originalEvent: PointerEvent;
117
+ delta: {
118
+ x: number;
119
+ y: number;
120
+ };
121
+ }>, "currentTarget">) => any) | undefined;
122
+ }>, {
123
+ close: ButtonProps | boolean;
124
+ orientation: "horizontal" | "vertical";
125
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ToastSlots>;
126
+ export default _default;
127
+ type __VLS_WithSlots<T, S> = T & {
128
+ new (): {
129
+ $slots: S;
130
+ };
131
+ };
@@ -1,100 +1,62 @@
1
- <script lang="ts">
2
- import type { VariantProps } from '@byyuurin/ui-kit'
3
- import type { ToastProviderProps as RekaToastProviderProps } from 'reka-ui'
4
- import type { toastProvider } from '../theme'
5
- import type { ComponentAttrs, ToastProps } from '../types'
1
+ <script>
6
2
 
7
- export interface ToastState extends Omit<ToastProps, 'defaultOpen'> {
8
- id: string | number
9
- onClick?: (toast: ToastState) => void
10
- }
11
-
12
- export interface ToasterSlots {
13
- default?: (props?: {}) => any
14
- }
15
-
16
- type ToasterVariants = VariantProps<typeof toastProvider>
17
-
18
- export interface ToastProviderProps extends ComponentAttrs<typeof toastProvider>, Omit<RekaToastProviderProps, 'swipeDirection'> {
19
- /** @default "bottom-right" */
20
- position?: ToasterVariants['position']
21
- /**
22
- * Expand the toasts to show multiple toasts at once.
23
- * @default true
24
- */
25
- expand?: boolean
26
- /**
27
- * Render the toaster in a portal.
28
- * @default true
29
- */
30
- portal?: boolean
31
- }
32
3
  </script>
33
4
 
34
- <script setup lang="ts">
35
- import { reactivePick } from '@vueuse/core'
36
- import { ToastPortal, ToastProvider, ToastViewport, useForwardProps } from 'reka-ui'
37
- import { computed, ref } from 'vue'
38
- import { useTheme } from '../composables/useTheme'
39
- import { useToast } from '../composables/useToast'
40
- import { omit } from '../utils'
41
- import Toast from './Toast.vue'
42
-
43
- const props = withDefaults(defineProps<ToastProviderProps>(), {
44
- position: 'bottom-right',
45
- expand: true,
46
- portal: true,
47
- duration: 5000,
48
- })
49
- defineSlots<ToasterSlots>()
50
-
51
- const providerProps = useForwardProps(reactivePick(props, 'duration', 'label', 'swipeThreshold'))
52
-
53
- const { toasts, remove } = useToast()
54
-
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { ToastPortal, ToastProvider, ToastViewport, useForwardProps } from "reka-ui";
8
+ import { computed, ref } from "vue";
9
+ import { useTheme } from "../composables/useTheme";
10
+ import { useToast } from "../composables/useToast";
11
+ import { omit } from "../utils";
12
+ import Toast from "./Toast.vue";
13
+ const props = defineProps({
14
+ position: { type: null, required: false, default: "bottom-right" },
15
+ expand: { type: Boolean, required: false, default: true },
16
+ portal: { type: Boolean, required: false, default: true },
17
+ class: { type: null, required: false },
18
+ ui: { type: null, required: false },
19
+ label: { type: String, required: false },
20
+ duration: { type: Number, required: false, default: 5e3 },
21
+ swipeThreshold: { type: Number, required: false }
22
+ });
23
+ defineSlots();
24
+ const providerProps = useForwardProps(reactivePick(props, "duration", "label", "swipeThreshold"));
25
+ const { toasts, remove } = useToast();
55
26
  const swipeDirection = computed(() => {
56
27
  switch (props.position) {
57
- case 'top-center':
58
- return 'up'
59
- case 'top-right':
60
- case 'bottom-right':
61
- return 'right'
62
- case 'bottom-center':
63
- return 'down'
64
- case 'top-left':
65
- case 'bottom-left':
66
- return 'left'
28
+ case "top-center":
29
+ return "up";
30
+ case "top-right":
31
+ case "bottom-right":
32
+ return "right";
33
+ case "bottom-center":
34
+ return "down";
35
+ case "top-left":
36
+ case "bottom-left":
37
+ return "left";
67
38
  }
68
-
69
- console.warn(`[ToastProvider] Unknown position "${props.position}"`)
70
-
71
- return 'right'
72
- })
73
-
74
- const { generateStyle } = useTheme()
75
- const style = computed(() => generateStyle('toastProvider', {
39
+ console.warn(`[ToastProvider] Unknown position "${props.position}"`);
40
+ return "right";
41
+ });
42
+ const { generateStyle } = useTheme();
43
+ const style = computed(() => generateStyle("toastProvider", {
76
44
  ...props,
77
45
  swipeDirection: swipeDirection.value,
78
- clickable: false,
79
- }))
80
-
81
- function onUpdateOpen(value: boolean, id: string | number) {
46
+ clickable: false
47
+ }));
48
+ function onUpdateOpen(value, id) {
82
49
  if (value)
83
- return
84
-
85
- remove(id)
50
+ return;
51
+ remove(id);
86
52
  }
87
-
88
- const hovered = ref(false)
89
- const expanded = computed(() => props.expand || hovered.value)
90
-
91
- const refs = ref<{ height: number }[]>([])
92
-
93
- const height = computed(() => refs.value.reduce((sum, { height }) => sum + height + 16, 0))
94
- const frontHeight = computed(() => refs.value[refs.value.length - 1]?.height || 0)
95
-
96
- function getOffset(index: number) {
97
- return refs.value.slice(index + 1).reduce((acc, { height }) => acc + height + 16, 0)
53
+ const hovered = ref(false);
54
+ const expanded = computed(() => props.expand || hovered.value);
55
+ const refs = ref([]);
56
+ const height = computed(() => refs.value.reduce((sum, { height: height2 }) => sum + height2 + 16, 0));
57
+ const frontHeight = computed(() => refs.value[refs.value.length - 1]?.height || 0);
58
+ function getOffset(index) {
59
+ return refs.value.slice(index + 1).reduce((acc, { height: height2 }) => acc + height2 + 16, 0);
98
60
  }
99
61
  </script>
100
62
 
@@ -110,14 +72,15 @@ function getOffset(index: number) {
110
72
  :data-expanded="expanded"
111
73
  :data-front="!expanded && index === toasts.length - 1"
112
74
  :style="{
113
- '--index': (index - toasts.length) + toasts.length,
114
- '--before': toasts.length - 1 - index,
115
- '--offset': getOffset(index),
116
- '--scale': expanded ? '1' : 'calc(1 - var(--before) * var(--scale-factor))',
117
- '--translate': expanded ? 'calc(var(--offset) * var(--translate-factor))' : 'calc(var(--before) * var(--gap))',
118
- '--transform': 'translateY(var(--translate)) scale(var(--scale))',
119
- }"
120
- :class="style.base({ clickable: !!(toast.onClick) })"
75
+ '--index': index - toasts.length + toasts.length,
76
+ '--before': toasts.length - 1 - index,
77
+ '--offset': getOffset(index),
78
+ '--scale': expanded ? '1' : 'calc(1 - var(--before) * var(--scale-factor))',
79
+ '--translate': expanded ? 'calc(var(--offset) * var(--translate-factor))' : 'calc(var(--before) * var(--gap))',
80
+ '--transform': 'translateY(var(--translate)) scale(var(--scale))'
81
+ }"
82
+ :class="style.base({ clickable: !!toast.onClick })"
83
+ data-part="base"
121
84
  @update:open="onUpdateOpen($event, toast.id)"
122
85
  @click="toast.onClick && toast.onClick(toast)"
123
86
  />
@@ -126,13 +89,14 @@ function getOffset(index: number) {
126
89
  <ToastViewport
127
90
  :data-expanded="expanded"
128
91
  :class="style.viewport({ class: [props.class, props.ui?.viewport] })"
92
+ data-part="viewport"
129
93
  :style="{
130
- '--scale-factor': '0.05',
131
- '--translate-factor': position?.startsWith('top') ? '1px' : '-1px',
132
- '--gap': position?.startsWith('top') ? '16px' : '-16px',
133
- '--front-height': `${frontHeight}px`,
134
- '--height': `${height}px`,
135
- }"
94
+ '--scale-factor': '0.05',
95
+ '--translate-factor': position?.startsWith('top') ? '1px' : '-1px',
96
+ '--gap': position?.startsWith('top') ? '16px' : '-16px',
97
+ '--front-height': `${frontHeight}px`,
98
+ '--height': `${height}px`
99
+ }"
136
100
  @mouseenter="hovered = true"
137
101
  @mouseleave="hovered = false"
138
102
  />
@@ -0,0 +1,38 @@
1
+ import type { VariantProps } from '@byyuurin/ui-kit';
2
+ import type { ToastProviderProps as RekaToastProviderProps } from 'reka-ui';
3
+ import type { toastProvider } from '../theme/index.js';
4
+ import type { ComponentAttrs, ToastProps } from '../types/index.js';
5
+ export interface ToastState extends Omit<ToastProps, 'defaultOpen'> {
6
+ id: string | number;
7
+ onClick?: (toast: ToastState) => void;
8
+ }
9
+ export interface ToasterSlots {
10
+ default?: (props?: {}) => any;
11
+ }
12
+ type ToasterVariants = VariantProps<typeof toastProvider>;
13
+ export interface ToastProviderProps extends ComponentAttrs<typeof toastProvider>, Omit<RekaToastProviderProps, 'swipeDirection'> {
14
+ /** @default "bottom-right" */
15
+ position?: ToasterVariants['position'];
16
+ /**
17
+ * Expand the toasts to show multiple toasts at once.
18
+ * @default true
19
+ */
20
+ expand?: boolean;
21
+ /**
22
+ * Render the toaster in a portal.
23
+ * @default true
24
+ */
25
+ portal?: boolean;
26
+ }
27
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<ToastProviderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ToastProviderProps> & Readonly<{}>, {
28
+ position: "top-right" | "bottom-right" | "top-left" | "bottom-left" | "top-center" | "bottom-center";
29
+ duration: number;
30
+ expand: boolean;
31
+ portal: boolean;
32
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ToasterSlots>;
33
+ export default _default;
34
+ type __VLS_WithSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
@@ -1,51 +1,40 @@
1
- <script lang="ts">
2
- import type { TooltipArrowProps, TooltipContentProps, TooltipRootEmits, TooltipRootProps } from 'reka-ui'
3
- import type { tooltip } from '../theme'
4
- import type { ComponentAttrs } from '../types'
1
+ <script>
5
2
 
6
- export interface TooltipEmits extends TooltipRootEmits {}
7
-
8
- export interface TooltipSlots {
9
- default?: (props: { open: boolean }) => any
10
- content?: (props: {}) => any
11
- }
12
-
13
- export interface TooltipProps extends ComponentAttrs<typeof tooltip>, TooltipRootProps {
14
- text?: string
15
- content?: Omit<TooltipContentProps, 'as' | 'asChild'>
16
- arrow?: boolean | Omit<TooltipArrowProps, 'as' | 'asChild'>
17
- /** @default true */
18
- portal?: boolean
19
- }
20
3
  </script>
21
4
 
22
- <script lang="ts" setup>
23
- import { reactivePick } from '@vueuse/core'
24
- import { defu } from 'defu'
25
- import { TooltipArrow, TooltipContent, TooltipPortal, TooltipRoot, TooltipTrigger, useForwardPropsEmits } from 'reka-ui'
26
- import { computed, toRef } from 'vue'
27
- import { useTheme } from '../composables/useTheme'
28
-
29
- const props = withDefaults(defineProps<TooltipProps>(), {
30
- portal: true,
31
- })
32
- const emit = defineEmits<TooltipEmits>()
33
- const slots = defineSlots<TooltipSlots>()
34
-
35
- const rootProps = useForwardPropsEmits(reactivePick(props, 'defaultOpen', 'open', 'delayDuration', 'disableHoverableContent', 'disableClosingTrigger', 'disabled', 'ignoreNonKeyboardFocus'), emit)
36
-
37
- const contentDefaults: TooltipContentProps = {
38
- side: 'bottom',
5
+ <script setup>
6
+ import { reactivePick } from "@vueuse/core";
7
+ import { defu } from "defu";
8
+ import { TooltipArrow, TooltipContent, TooltipPortal, TooltipRoot, TooltipTrigger, useForwardPropsEmits } from "reka-ui";
9
+ import { computed, toRef } from "vue";
10
+ import { useTheme } from "../composables/useTheme";
11
+ const props = defineProps({
12
+ text: { type: String, required: false },
13
+ content: { type: Object, required: false },
14
+ arrow: { type: [Boolean, Object], required: false },
15
+ portal: { type: Boolean, required: false, default: true },
16
+ class: { type: null, required: false },
17
+ ui: { type: null, required: false },
18
+ defaultOpen: { type: Boolean, required: false },
19
+ open: { type: Boolean, required: false },
20
+ delayDuration: { type: Number, required: false },
21
+ disableHoverableContent: { type: Boolean, required: false },
22
+ disableClosingTrigger: { type: Boolean, required: false },
23
+ disabled: { type: Boolean, required: false },
24
+ ignoreNonKeyboardFocus: { type: Boolean, required: false }
25
+ });
26
+ const emit = defineEmits(["update:open"]);
27
+ const slots = defineSlots();
28
+ const rootProps = useForwardPropsEmits(reactivePick(props, "defaultOpen", "open", "delayDuration", "disableHoverableContent", "disableClosingTrigger", "disabled", "ignoreNonKeyboardFocus"), emit);
29
+ const contentDefaults = {
30
+ side: "bottom",
39
31
  sideOffset: 8,
40
- collisionPadding: 8,
41
- }
42
-
43
- const contentProps = toRef(() => defu(props.content, contentDefaults) as TooltipContentProps)
44
-
45
- const arrowProps = toRef(() => props.arrow as TooltipArrowProps)
46
-
47
- const { generateStyle } = useTheme()
48
- const style = computed(() => generateStyle('tooltip', props))
32
+ collisionPadding: 8
33
+ };
34
+ const contentProps = toRef(() => defu(props.content, contentDefaults));
35
+ const arrowProps = toRef(() => props.arrow);
36
+ const { generateStyle } = useTheme();
37
+ const style = computed(() => generateStyle("tooltip", props));
49
38
  </script>
50
39
 
51
40
  <template>
@@ -56,12 +45,12 @@ const style = computed(() => generateStyle('tooltip', props))
56
45
  </TooltipTrigger>
57
46
 
58
47
  <TooltipPortal :disabled="!props.portal">
59
- <TooltipContent v-bind="contentProps" :class="style.content({ class: [!slots.default && props.class, props.ui?.content] })">
48
+ <TooltipContent v-bind="contentProps" :class="style.content({ class: [!slots.default && props.class, props.ui?.content] })" data-part="content">
60
49
  <slot name="content">
61
- <span v-if="props.text" :class="style.text({ class: props.ui?.text })">{{ props.text }}</span>
50
+ <span v-if="props.text" :class="style.text({ class: props.ui?.text })" data-part="text">{{ props.text }}</span>
62
51
  </slot>
63
52
 
64
- <TooltipArrow v-if="props.arrow" v-bind="arrowProps" :class="style.arrow({ class: props.ui?.arrow })" />
53
+ <TooltipArrow v-if="props.arrow" v-bind="arrowProps" :class="style.arrow({ class: props.ui?.arrow })" data-part="arrow" />
65
54
  </TooltipContent>
66
55
  </TooltipPortal>
67
56
  </TooltipRoot>