@byyuurin/ui 0.0.10 → 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 (194) hide show
  1. package/README.md +2 -2
  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 +388 -364
  6. package/dist/runtime/components/Accordion.vue +38 -67
  7. package/dist/runtime/components/Accordion.vue.d.ts +52 -0
  8. package/dist/runtime/components/Alert.vue +37 -75
  9. package/dist/runtime/components/Alert.vue.d.ts +59 -0
  10. package/dist/runtime/components/App.vue +25 -40
  11. package/dist/runtime/components/App.vue.d.ts +24 -0
  12. package/dist/runtime/components/Avatar.vue +31 -51
  13. package/dist/runtime/components/Avatar.vue.d.ts +25 -0
  14. package/dist/runtime/components/AvatarGroup.vue +38 -69
  15. package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
  16. package/dist/runtime/components/Badge.vue +25 -51
  17. package/dist/runtime/components/Badge.vue.d.ts +44 -0
  18. package/dist/runtime/components/Breadcrumb.vue +36 -74
  19. package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
  20. package/dist/runtime/components/Button.vue +62 -51
  21. package/dist/runtime/components/Button.vue.d.ts +29 -0
  22. package/dist/runtime/components/ButtonGroup.vue +17 -37
  23. package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
  24. package/dist/runtime/components/Calendar.vue +75 -110
  25. package/dist/runtime/components/Calendar.vue.d.ts +75 -0
  26. package/dist/runtime/components/Card.vue +25 -42
  27. package/dist/runtime/components/Card.vue.d.ts +30 -0
  28. package/dist/runtime/components/Carousel.vue +118 -225
  29. package/dist/runtime/components/Carousel.vue.d.ts +104 -0
  30. package/dist/runtime/components/Checkbox.vue +46 -73
  31. package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
  32. package/dist/runtime/components/Chip.vue +31 -48
  33. package/dist/runtime/components/Chip.vue.d.ts +30 -0
  34. package/dist/runtime/components/Collapsible.vue +22 -30
  35. package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
  36. package/dist/runtime/components/Drawer.vue +51 -101
  37. package/dist/runtime/components/Drawer.vue.d.ts +80 -0
  38. package/dist/runtime/components/DropdownMenu.vue +37 -115
  39. package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
  40. package/dist/runtime/components/DropdownMenuContent.vue +81 -77
  41. package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
  42. package/dist/runtime/components/Form.vue +140 -254
  43. package/dist/runtime/components/Form.vue.d.ts +78 -0
  44. package/dist/runtime/components/FormItem.vue +50 -89
  45. package/dist/runtime/components/FormItem.vue.d.ts +60 -0
  46. package/dist/runtime/components/Input.vue +79 -115
  47. package/dist/runtime/components/Input.vue.d.ts +64 -0
  48. package/dist/runtime/components/InputNumber.vue +74 -117
  49. package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
  50. package/dist/runtime/components/Kbd.vue +18 -39
  51. package/dist/runtime/components/Kbd.vue.d.ts +28 -0
  52. package/dist/runtime/components/Link.vue +168 -257
  53. package/dist/runtime/components/Link.vue.d.ts +95 -0
  54. package/dist/runtime/components/LinkBase.vue +36 -54
  55. package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
  56. package/dist/runtime/components/Modal.vue +49 -84
  57. package/dist/runtime/components/Modal.vue.d.ts +66 -0
  58. package/dist/runtime/components/OverlayProvider.vue +10 -14
  59. package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
  60. package/dist/runtime/components/Pagination.vue +55 -121
  61. package/dist/runtime/components/Pagination.vue.d.ts +93 -0
  62. package/dist/runtime/components/PinInput.vue +49 -58
  63. package/dist/runtime/components/PinInput.vue.d.ts +35 -0
  64. package/dist/runtime/components/Popover.vue +39 -68
  65. package/dist/runtime/components/Popover.vue.d.ts +45 -0
  66. package/dist/runtime/components/Progress.vue +68 -120
  67. package/dist/runtime/components/Progress.vue.d.ts +54 -0
  68. package/dist/runtime/components/RadioGroup.vue +67 -125
  69. package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
  70. package/dist/runtime/components/ScrollArea.vue +31 -31
  71. package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
  72. package/dist/runtime/components/Select.vue +114 -204
  73. package/dist/runtime/components/Select.vue.d.ts +119 -0
  74. package/dist/runtime/components/Separator.vue +26 -44
  75. package/dist/runtime/components/Separator.vue.d.ts +27 -0
  76. package/dist/runtime/components/Skeleton.vue +12 -21
  77. package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
  78. package/dist/runtime/components/Slider.vue +52 -74
  79. package/dist/runtime/components/Slider.vue.d.ts +36 -0
  80. package/dist/runtime/components/Switch.vue +51 -71
  81. package/dist/runtime/components/Switch.vue.d.ts +49 -0
  82. package/dist/runtime/components/Table.vue +108 -194
  83. package/dist/runtime/components/Table.vue.d.ts +148 -0
  84. package/dist/runtime/components/Tabs.vue +36 -81
  85. package/dist/runtime/components/Tabs.vue.d.ts +65 -0
  86. package/dist/runtime/components/Textarea.vue +77 -124
  87. package/dist/runtime/components/Textarea.vue.d.ts +60 -0
  88. package/dist/runtime/components/Toast.vue +47 -75
  89. package/dist/runtime/components/Toast.vue.d.ts +131 -0
  90. package/dist/runtime/components/ToastProvider.vue +65 -101
  91. package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
  92. package/dist/runtime/components/Tooltip.vue +36 -47
  93. package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
  94. package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
  95. package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
  96. package/dist/runtime/composables/useFormItem.d.ts +2 -2
  97. package/dist/runtime/composables/useKbd.d.ts +1 -1
  98. package/dist/runtime/composables/useLocale.d.ts +3 -3
  99. package/dist/runtime/composables/useTheme.d.ts +1 -1
  100. package/dist/runtime/composables/useToast.d.ts +1 -1
  101. package/dist/runtime/locale/en.d.ts +1 -1
  102. package/dist/runtime/locale/zh-tw.d.ts +1 -1
  103. package/dist/runtime/theme/accordion.d.ts +45 -51
  104. package/dist/runtime/theme/accordion.js +1 -1
  105. package/dist/runtime/theme/alert.d.ts +115 -121
  106. package/dist/runtime/theme/alert.js +1 -1
  107. package/dist/runtime/theme/avatar-group.d.ts +42 -48
  108. package/dist/runtime/theme/avatar-group.js +1 -1
  109. package/dist/runtime/theme/avatar.d.ts +46 -52
  110. package/dist/runtime/theme/avatar.js +1 -1
  111. package/dist/runtime/theme/badge.d.ts +60 -66
  112. package/dist/runtime/theme/badge.js +1 -1
  113. package/dist/runtime/theme/breadcrumb.d.ts +52 -58
  114. package/dist/runtime/theme/breadcrumb.js +1 -1
  115. package/dist/runtime/theme/button-group.d.ts +36 -42
  116. package/dist/runtime/theme/button.d.ts +162 -168
  117. package/dist/runtime/theme/button.js +1 -1
  118. package/dist/runtime/theme/calendar.d.ts +52 -50
  119. package/dist/runtime/theme/calendar.js +20 -3
  120. package/dist/runtime/theme/card.d.ts +52 -58
  121. package/dist/runtime/theme/card.js +1 -1
  122. package/dist/runtime/theme/carousel.d.ts +98 -104
  123. package/dist/runtime/theme/carousel.js +1 -1
  124. package/dist/runtime/theme/checkbox.d.ts +77 -83
  125. package/dist/runtime/theme/checkbox.js +1 -1
  126. package/dist/runtime/theme/chip.d.ts +50 -56
  127. package/dist/runtime/theme/chip.js +1 -1
  128. package/dist/runtime/theme/collapsible.d.ts +29 -35
  129. package/dist/runtime/theme/collapsible.js +1 -1
  130. package/dist/runtime/theme/drawer.d.ts +120 -126
  131. package/dist/runtime/theme/drawer.js +1 -1
  132. package/dist/runtime/theme/dropdown-menu.d.ts +55 -61
  133. package/dist/runtime/theme/dropdown-menu.js +1 -1
  134. package/dist/runtime/theme/form-item.d.ts +63 -69
  135. package/dist/runtime/theme/form-item.js +1 -1
  136. package/dist/runtime/theme/form.d.ts +1 -7
  137. package/dist/runtime/theme/input-number.d.ts +98 -104
  138. package/dist/runtime/theme/input-number.js +1 -1
  139. package/dist/runtime/theme/input.d.ts +153 -159
  140. package/dist/runtime/theme/input.js +1 -1
  141. package/dist/runtime/theme/kbd.d.ts +30 -36
  142. package/dist/runtime/theme/link.d.ts +37 -43
  143. package/dist/runtime/theme/modal.d.ts +36 -42
  144. package/dist/runtime/theme/modal.js +1 -1
  145. package/dist/runtime/theme/pagination.d.ts +71 -77
  146. package/dist/runtime/theme/pagination.js +1 -1
  147. package/dist/runtime/theme/pinInput.d.ts +80 -86
  148. package/dist/runtime/theme/pinInput.js +1 -1
  149. package/dist/runtime/theme/popover.d.ts +29 -35
  150. package/dist/runtime/theme/popover.js +1 -1
  151. package/dist/runtime/theme/progress.d.ts +163 -169
  152. package/dist/runtime/theme/progress.js +1 -1
  153. package/dist/runtime/theme/radio-group.d.ts +99 -105
  154. package/dist/runtime/theme/radio-group.js +1 -1
  155. package/dist/runtime/theme/scroll-area.d.ts +62 -68
  156. package/dist/runtime/theme/scroll-area.js +1 -1
  157. package/dist/runtime/theme/select.d.ts +165 -171
  158. package/dist/runtime/theme/select.js +1 -1
  159. package/dist/runtime/theme/separator.d.ts +62 -68
  160. package/dist/runtime/theme/separator.js +1 -1
  161. package/dist/runtime/theme/skeleton.d.ts +1 -7
  162. package/dist/runtime/theme/slider.d.ts +62 -68
  163. package/dist/runtime/theme/slider.js +1 -1
  164. package/dist/runtime/theme/switch.d.ts +111 -117
  165. package/dist/runtime/theme/switch.js +1 -1
  166. package/dist/runtime/theme/table.d.ts +75 -81
  167. package/dist/runtime/theme/table.js +1 -1
  168. package/dist/runtime/theme/tabs.d.ts +114 -120
  169. package/dist/runtime/theme/tabs.js +1 -1
  170. package/dist/runtime/theme/textarea.d.ts +76 -82
  171. package/dist/runtime/theme/textarea.js +1 -1
  172. package/dist/runtime/theme/toast-provider.d.ts +106 -112
  173. package/dist/runtime/theme/toast-provider.js +1 -1
  174. package/dist/runtime/theme/toast.d.ts +74 -80
  175. package/dist/runtime/theme/toast.js +1 -1
  176. package/dist/runtime/theme/tooltip.d.ts +35 -41
  177. package/dist/runtime/theme/tooltip.js +1 -1
  178. package/dist/runtime/types/utils.d.ts +5 -5
  179. package/dist/runtime/utils/link.d.ts +3 -5
  180. package/dist/runtime/utils/styler.d.ts +2 -2
  181. package/dist/runtime/utils/styler.js +2 -2
  182. package/dist/shared/ui.D1BTWZFB.mjs +5 -0
  183. package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
  184. package/dist/types.d.mts +1 -1
  185. package/dist/unocss.mjs +5 -4
  186. package/dist/unocss.mjs.map +1 -1
  187. package/dist/unplugin.mjs +1 -1
  188. package/dist/unplugin.mjs.map +1 -1
  189. package/dist/vite.mjs +1 -1
  190. package/package.json +77 -75
  191. package/dist/module.cjs +0 -5
  192. package/dist/shared/ui.3e7fad19.mjs +0 -5
  193. package/dist/shared/ui.3e7fad19.mjs.map +0 -1
  194. 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: ComponentAttrs<typeof toast>['ui'] }) => 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" />
@@ -106,8 +76,9 @@ defineExpose({
106
76
  </div>
107
77
 
108
78
  <div
109
- v-if="(props.orientation === 'horizontal' && actions?.length) || props.close || slots.close"
79
+ v-if="props.orientation === 'horizontal' && actions?.length || props.close || slots.close"
110
80
  :class="style.actions({ class: props.ui?.actions })"
81
+ data-part="actions"
111
82
  >
112
83
  <template v-if="props.orientation === 'horizontal'">
113
84
  <slot name="actions">
@@ -124,14 +95,15 @@ defineExpose({
124
95
  size="sm"
125
96
  variant="link"
126
97
  :aria-label="t('toast.close')"
127
- v-bind="typeof close === 'object' ? close : undefined"
98
+ v-bind="typeof close === 'object' ? close : void 0"
128
99
  :class="style.close({ class: props.ui?.close })"
100
+ data-part="close"
129
101
  @click.stop
130
102
  />
131
103
  </slot>
132
104
  </ToastClose>
133
105
  </div>
134
106
 
135
- <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>
136
108
  </ToastRoot>
137
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, TooltipContentEmits, TooltipContentProps, TooltipRootEmits, TooltipRootProps } from 'reka-ui'
3
- import type { tooltip } from '../theme'
4
- import type { ComponentAttrs, EmitsToProps } 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'> & Partial<EmitsToProps<TooltipContentEmits>>
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>