@byyuurin/ui 0.0.5 → 0.0.6
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.
- package/README.md +13 -8
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +3 -0
- package/dist/nuxt.mjs +4 -3
- package/dist/nuxt.mjs.map +1 -1
- package/dist/runtime/components/App.vue +1 -1
- package/dist/runtime/components/Badge.vue +0 -1
- package/dist/runtime/components/Button.vue +4 -1
- package/dist/runtime/components/ButtonGroup.vue +47 -0
- package/dist/runtime/components/Carousel.vue +310 -0
- package/dist/runtime/components/Checkbox.vue +0 -1
- package/dist/runtime/components/Chip.vue +7 -2
- package/dist/runtime/components/Input.vue +8 -4
- package/dist/runtime/components/Modal.vue +2 -3
- package/dist/runtime/components/Pagination.vue +167 -0
- package/dist/runtime/components/PinInput.vue +0 -1
- package/dist/runtime/components/RadioGroup.vue +0 -1
- package/dist/runtime/components/ScrollArea.vue +1 -1
- package/dist/runtime/components/Select.vue +5 -1
- package/dist/runtime/components/Slider.vue +0 -1
- package/dist/runtime/components/Switch.vue +1 -3
- package/dist/runtime/components/Tabs.vue +0 -1
- package/dist/runtime/components/Textarea.vue +0 -1
- package/dist/runtime/components/Toast.vue +20 -9
- package/dist/runtime/components/Toaster.vue +3 -4
- package/dist/runtime/composables/useButtonGroup.d.ts +13 -0
- package/dist/runtime/composables/useButtonGroup.mjs +14 -0
- package/dist/runtime/composables/useTheme.d.ts +2 -2
- package/dist/runtime/composables/useTheme.mjs +1 -1
- package/dist/runtime/composables/useToast.d.ts +4 -4
- package/dist/runtime/composables/useToast.mjs +19 -6
- package/dist/runtime/theme/accordion.d.ts +17 -0
- package/dist/runtime/theme/alert.d.ts +40 -0
- package/dist/runtime/theme/alert.mjs +4 -4
- package/dist/runtime/theme/app.d.ts +5 -0
- package/dist/runtime/theme/app.mjs +6 -1
- package/dist/runtime/theme/badge.d.ts +3 -0
- package/dist/runtime/theme/badge.mjs +5 -2
- package/dist/runtime/theme/button-group.d.ts +66 -0
- package/dist/runtime/theme/button-group.mjs +42 -0
- package/dist/runtime/theme/button.d.ts +11 -0
- package/dist/runtime/theme/button.mjs +23 -18
- package/dist/runtime/theme/card.d.ts +19 -0
- package/dist/runtime/theme/card.mjs +1 -1
- package/dist/runtime/theme/carousel.d.ts +113 -0
- package/dist/runtime/theme/carousel.mjs +43 -0
- package/dist/runtime/theme/checkbox.d.ts +3 -0
- package/dist/runtime/theme/checkbox.mjs +6 -3
- package/dist/runtime/theme/chip.d.ts +11 -0
- package/dist/runtime/theme/chip.mjs +10 -5
- package/dist/runtime/theme/drawer.d.ts +38 -0
- package/dist/runtime/theme/drawer.mjs +2 -2
- package/dist/runtime/theme/index.d.ts +5 -2
- package/dist/runtime/theme/index.mjs +5 -2
- package/dist/runtime/theme/input.d.ts +33 -22
- package/dist/runtime/theme/input.mjs +36 -31
- package/dist/runtime/theme/link.d.ts +13 -0
- package/dist/runtime/theme/modal.d.ts +3 -0
- package/dist/runtime/theme/modal.mjs +5 -2
- package/dist/runtime/theme/pagination.d.ts +56 -0
- package/dist/runtime/theme/pagination.mjs +13 -0
- package/dist/runtime/theme/pinInput.d.ts +3 -0
- package/dist/runtime/theme/pinInput.mjs +14 -11
- package/dist/runtime/theme/popover.d.ts +11 -0
- package/dist/runtime/theme/popover.mjs +1 -1
- package/dist/runtime/theme/{radioGroup.d.ts → radio-group.d.ts} +3 -0
- package/dist/runtime/theme/{radioGroup.mjs → radio-group.mjs} +4 -1
- package/dist/runtime/theme/{scrollArea.d.ts → scroll-area.d.ts} +22 -0
- package/dist/runtime/theme/{scrollArea.mjs → scroll-area.mjs} +2 -2
- package/dist/runtime/theme/select.d.ts +11 -0
- package/dist/runtime/theme/select.mjs +20 -15
- package/dist/runtime/theme/slider.d.ts +3 -0
- package/dist/runtime/theme/slider.mjs +6 -3
- package/dist/runtime/theme/switch.d.ts +3 -0
- package/dist/runtime/theme/switch.mjs +5 -2
- package/dist/runtime/theme/tabs.d.ts +3 -0
- package/dist/runtime/theme/tabs.mjs +13 -10
- package/dist/runtime/theme/textarea.d.ts +3 -0
- package/dist/runtime/theme/textarea.mjs +14 -11
- package/dist/runtime/theme/toast.d.ts +44 -6
- package/dist/runtime/theme/toast.mjs +12 -7
- package/dist/runtime/theme/toaster.d.ts +49 -0
- package/dist/runtime/theme/toaster.mjs +5 -0
- package/dist/runtime/theme/tooltip.d.ts +13 -0
- package/dist/runtime/theme/tooltip.mjs +1 -1
- package/dist/runtime/types/components.d.ts +27 -25
- package/dist/runtime/types/components.mjs +27 -0
- package/dist/runtime/types/utils.d.ts +1 -1
- package/dist/runtime/utils/styler.d.ts +2 -2
- package/dist/shared/ui.D4zm1r0C.mjs +4 -0
- package/dist/shared/ui.D4zm1r0C.mjs.map +1 -0
- package/dist/{unocss-preset.d.mts → unocss.d.mts} +4 -4
- package/dist/{unocss-preset.d.ts → unocss.d.ts} +4 -4
- package/dist/{unocss-preset.mjs → unocss.mjs} +15 -2
- package/dist/unocss.mjs.map +1 -0
- package/dist/unplugin.d.mts +4 -3
- package/dist/unplugin.d.ts +4 -3
- package/dist/unplugin.mjs +13 -5
- package/dist/unplugin.mjs.map +1 -1
- package/dist/vite.d.mts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.mjs +5 -5
- package/dist/vite.mjs.map +1 -1
- package/package.json +35 -22
- package/dist/shared/ui.CzDyI29e.mjs +0 -8
- package/dist/shared/ui.CzDyI29e.mjs.map +0 -1
- package/dist/unocss-preset.mjs.map +0 -1
- /package/{LICENSE.md → LICENSE} +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PaginationRootEmits, PaginationRootProps } from 'reka-ui'
|
|
3
|
+
import type { pagination } from '../theme'
|
|
4
|
+
import type { ButtonProps, ComponentAttrs } from '../types'
|
|
5
|
+
|
|
6
|
+
export interface PaginationProps extends ComponentAttrs<typeof pagination>, Pick<PaginationRootProps, 'as' | 'defaultPage' | 'disabled' | 'itemsPerPage' | 'page' | 'showEdges' | 'siblingCount' | 'total'> {
|
|
7
|
+
/**
|
|
8
|
+
* The icon to use for the first page control.
|
|
9
|
+
* @default app.icons.doubleLeft
|
|
10
|
+
*/
|
|
11
|
+
firstIcon?: string
|
|
12
|
+
/**
|
|
13
|
+
* The icon to use for the last page control.
|
|
14
|
+
* @default app.icons.doubleRight
|
|
15
|
+
*/
|
|
16
|
+
lastIcon?: string
|
|
17
|
+
/**
|
|
18
|
+
* The icon to use for the previous page control.
|
|
19
|
+
* @default app.icons.arrowLeft
|
|
20
|
+
*/
|
|
21
|
+
prevIcon?: string
|
|
22
|
+
/**
|
|
23
|
+
* The icon to use for the next page control.
|
|
24
|
+
* @default app.icons.arrowRight
|
|
25
|
+
*/
|
|
26
|
+
nextIcon?: string
|
|
27
|
+
/**
|
|
28
|
+
* The icon to use for the ellipsis control.
|
|
29
|
+
* @default app.icons.ellipsis
|
|
30
|
+
*/
|
|
31
|
+
ellipsisIcon?: string
|
|
32
|
+
/**
|
|
33
|
+
* The size of the pagination controls.
|
|
34
|
+
* @default 'md'
|
|
35
|
+
*/
|
|
36
|
+
size?: ButtonProps['size']
|
|
37
|
+
/**
|
|
38
|
+
* The variant of the pagination controls.
|
|
39
|
+
* @default 'outline'
|
|
40
|
+
*/
|
|
41
|
+
variant?: ButtonProps['variant']
|
|
42
|
+
/**
|
|
43
|
+
* The variant of the active pagination control.
|
|
44
|
+
* @default 'solid'
|
|
45
|
+
*/
|
|
46
|
+
activeVariant?: ButtonProps['variant']
|
|
47
|
+
/**
|
|
48
|
+
* Whether to show the first, previous, next, and last controls.
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
showControls?: boolean
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface PaginationEmits extends PaginationRootEmits {}
|
|
55
|
+
|
|
56
|
+
export interface PaginationSlots {
|
|
57
|
+
first?: (props?: {}) => any
|
|
58
|
+
prev?: (props?: {}) => any
|
|
59
|
+
next?: (props?: {}) => any
|
|
60
|
+
last?: (props?: {}) => any
|
|
61
|
+
ellipsis?: (props?: {}) => any
|
|
62
|
+
item?: (props: {
|
|
63
|
+
page: number
|
|
64
|
+
pageCount: number
|
|
65
|
+
item: {
|
|
66
|
+
type: 'ellipsis'
|
|
67
|
+
} | {
|
|
68
|
+
type: 'page'
|
|
69
|
+
value: number
|
|
70
|
+
}
|
|
71
|
+
index: number
|
|
72
|
+
}) => any
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<script setup lang="ts">
|
|
77
|
+
import { reactivePick } from '@vueuse/core'
|
|
78
|
+
import { PaginationEllipsis, PaginationFirst, PaginationLast, PaginationList, PaginationListItem, PaginationNext, PaginationPrev, PaginationRoot, useForwardPropsEmits } from 'reka-ui'
|
|
79
|
+
import { computed } from 'vue'
|
|
80
|
+
import { useTheme } from '../composables/useTheme'
|
|
81
|
+
import Button from './Button.vue'
|
|
82
|
+
|
|
83
|
+
const props = withDefaults(defineProps<PaginationProps>(), {
|
|
84
|
+
variant: 'outline',
|
|
85
|
+
activeVariant: 'solid',
|
|
86
|
+
showControls: true,
|
|
87
|
+
showEdges: false,
|
|
88
|
+
itemsPerPage: 10,
|
|
89
|
+
siblingCount: 2,
|
|
90
|
+
total: 0,
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const emit = defineEmits<PaginationEmits>()
|
|
94
|
+
const slots = defineSlots<PaginationSlots>()
|
|
95
|
+
|
|
96
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultPage', 'disabled', 'itemsPerPage', 'page', 'showEdges', 'siblingCount', 'total'), emit)
|
|
97
|
+
|
|
98
|
+
const { theme, createStyler } = useTheme()
|
|
99
|
+
|
|
100
|
+
const firstIcon = computed(() => props.firstIcon || theme.value.app.icons.doubleLeft)
|
|
101
|
+
const prevIcon = computed(() => props.prevIcon || theme.value.app.icons.arrowLeft)
|
|
102
|
+
const nextIcon = computed(() => props.nextIcon || theme.value.app.icons.arrowRight)
|
|
103
|
+
const lastIcon = computed(() => props.lastIcon || theme.value.app.icons.doubleRight)
|
|
104
|
+
const ellipsisIcon = computed(() => props.ellipsisIcon || theme.value.app.icons.ellipsis)
|
|
105
|
+
|
|
106
|
+
const style = computed(() => {
|
|
107
|
+
const styler = createStyler(theme.value.pagination)
|
|
108
|
+
return styler(props)
|
|
109
|
+
})
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<template>
|
|
113
|
+
<PaginationRoot v-slot="{ page, pageCount }" v-bind="rootProps" :class="style.root({ class: [props.class, props.ui?.root] })">
|
|
114
|
+
<PaginationList v-slot="{ items }" :class="style.list({ class: props.ui?.list })">
|
|
115
|
+
<PaginationFirst v-if="props.showControls || !!slots.first" as-child>
|
|
116
|
+
<slot name="first">
|
|
117
|
+
<Button :class="style.item({ class: props.ui?.item })" :variant="props.variant" :size="props.size" :icon="firstIcon" />
|
|
118
|
+
</slot>
|
|
119
|
+
</PaginationFirst>
|
|
120
|
+
<PaginationPrev v-if="props.showControls || !!slots.prev" as-child>
|
|
121
|
+
<slot name="prev">
|
|
122
|
+
<Button :class="style.item({ class: props.ui?.item })" :variant="props.variant" :size="props.size" :icon="prevIcon" />
|
|
123
|
+
</slot>
|
|
124
|
+
</PaginationPrev>
|
|
125
|
+
|
|
126
|
+
<template v-for="(item, index) in items">
|
|
127
|
+
<PaginationListItem v-if="item.type === 'page'" :key="index" as-child :value="item.value">
|
|
128
|
+
<slot name="item" v-bind="{ item, index, page, pageCount }">
|
|
129
|
+
<Button
|
|
130
|
+
:class="style.item({ class: props.ui?.item })"
|
|
131
|
+
:variant="props.page === item.value ? props.activeVariant : props.variant"
|
|
132
|
+
:size="props.size"
|
|
133
|
+
:label="String(item.value)"
|
|
134
|
+
:ui="{ label: style.label() }"
|
|
135
|
+
/>
|
|
136
|
+
</slot>
|
|
137
|
+
</PaginationListItem>
|
|
138
|
+
|
|
139
|
+
<PaginationEllipsis v-else :key="item.type" :index="index" as-child>
|
|
140
|
+
<slot name="ellipsis">
|
|
141
|
+
<Button
|
|
142
|
+
:variant="props.variant"
|
|
143
|
+
:size="props.size"
|
|
144
|
+
:icon="ellipsisIcon"
|
|
145
|
+
:disabled="props.disabled /* TODO: remove after reka-ui update */"
|
|
146
|
+
:class="[
|
|
147
|
+
style.item({ class: props.ui?.item }),
|
|
148
|
+
style.ellipsis({ class: props.ui?.ellipsis }),
|
|
149
|
+
]"
|
|
150
|
+
/>
|
|
151
|
+
</slot>
|
|
152
|
+
</PaginationEllipsis>
|
|
153
|
+
</template>
|
|
154
|
+
|
|
155
|
+
<PaginationNext v-if="props.showControls || !!slots.next" as-child>
|
|
156
|
+
<slot name="next">
|
|
157
|
+
<Button :class="style.item({ class: props.ui?.item })" :variant="props.variant" :size="props.size" :icon="nextIcon" />
|
|
158
|
+
</slot>
|
|
159
|
+
</PaginationNext>
|
|
160
|
+
<PaginationLast v-if="props.showControls || !!slots.last" as-child>
|
|
161
|
+
<slot name="last">
|
|
162
|
+
<Button :class="style.item({ class: props.ui?.item })" :variant="props.variant" :size="props.size" :icon="lastIcon" />
|
|
163
|
+
</slot>
|
|
164
|
+
</PaginationLast>
|
|
165
|
+
</PaginationList>
|
|
166
|
+
</PaginationRoot>
|
|
167
|
+
</template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { ScrollAreaRootProps } from 'reka-ui'
|
|
3
3
|
import type { scrollArea } from '../theme'
|
|
4
|
-
import { transitionProps } from '../theme/
|
|
4
|
+
import { transitionProps } from '../theme/scroll-area'
|
|
5
5
|
import type { ComponentAttrs } from '../types'
|
|
6
6
|
|
|
7
7
|
export interface ScrollAreaProps extends ComponentAttrs<typeof scrollArea>, Pick<ScrollAreaRootProps, 'type' | 'dir' | 'scrollHideDelay'> {}
|
|
@@ -105,13 +105,13 @@ import { reactivePick } from '@vueuse/core'
|
|
|
105
105
|
import { defu } from 'defu'
|
|
106
106
|
import { SelectArrow, SelectContent, SelectGroup, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectPortal, SelectRoot, SelectSeparator, SelectTrigger, SelectViewport, useForwardPropsEmits } from 'reka-ui'
|
|
107
107
|
import { computed, toRef } from 'vue'
|
|
108
|
+
import { useButtonGroup } from '../composables/useButtonGroup'
|
|
108
109
|
import { useComponentIcons } from '../composables/useComponentIcons'
|
|
109
110
|
import { useTheme } from '../composables/useTheme'
|
|
110
111
|
import { compare, get } from '../utils'
|
|
111
112
|
|
|
112
113
|
const props = withDefaults(defineProps<SelectProps<T, I, V, M>>(), {
|
|
113
114
|
variant: 'outline',
|
|
114
|
-
size: 'md',
|
|
115
115
|
valueKey: 'value' as never,
|
|
116
116
|
labelKey: 'label' as never,
|
|
117
117
|
portal: true,
|
|
@@ -125,6 +125,8 @@ const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffse
|
|
|
125
125
|
const arrowProps = toRef(() => props.arrow as SelectArrowProps)
|
|
126
126
|
|
|
127
127
|
const { theme, createStyler } = useTheme()
|
|
128
|
+
|
|
129
|
+
const { size, orientation } = useButtonGroup(props)
|
|
128
130
|
const { isPrefix, isSuffix, prefixIconName, suffixIconName } = useComponentIcons(toRef(() => defu(props, {
|
|
129
131
|
suffixIcon: theme.value.app.icons.down,
|
|
130
132
|
})))
|
|
@@ -136,6 +138,8 @@ const style = computed(() => {
|
|
|
136
138
|
const styler = createStyler(theme.value.select)
|
|
137
139
|
return styler({
|
|
138
140
|
...props,
|
|
141
|
+
size: size.value,
|
|
142
|
+
groupOrientation: orientation.value,
|
|
139
143
|
prefix: isPrefix.value,
|
|
140
144
|
suffix: isSuffix.value,
|
|
141
145
|
})
|
|
@@ -40,9 +40,7 @@ import { Label, Primitive, SwitchRoot, SwitchThumb, useForwardProps } from 'reka
|
|
|
40
40
|
import { computed, useId } from 'vue'
|
|
41
41
|
import { useTheme } from '../composables/useTheme'
|
|
42
42
|
|
|
43
|
-
const props = withDefaults(defineProps<SwitchProps>(), {
|
|
44
|
-
size: 'md',
|
|
45
|
-
})
|
|
43
|
+
const props = withDefaults(defineProps<SwitchProps>(), {})
|
|
46
44
|
const emit = defineEmits<SwitchEmits>()
|
|
47
45
|
const slots = defineSlots<SwitchSlots>()
|
|
48
46
|
const modelValue = defineModel<boolean>({ default: undefined })
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
2
3
|
import type { PrimitiveProps, ToastRootEmits, ToastRootProps } from 'reka-ui'
|
|
3
4
|
import type { toast } from '../theme'
|
|
4
5
|
import type { ButtonProps, ComponentAttrs } from '../types'
|
|
5
6
|
|
|
7
|
+
type ToastVariants = VariantProps<typeof toast>
|
|
8
|
+
|
|
6
9
|
export interface ToastProps extends ComponentAttrs<typeof toast>, Pick<ToastRootProps, 'defaultOpen' | 'open' | 'type' | 'duration'> {
|
|
7
10
|
/** @default "li" */
|
|
8
11
|
as?: PrimitiveProps['as']
|
|
9
12
|
title?: string
|
|
10
13
|
description?: string
|
|
11
14
|
icon?: string
|
|
15
|
+
orientation?: ToastVariants['orientation']
|
|
16
|
+
/**
|
|
17
|
+
* Display a list of actions:
|
|
18
|
+
* - under the title and description when orientation is `vertical`
|
|
19
|
+
* - next to the close button when orientation is `horizontal`
|
|
20
|
+
*/
|
|
12
21
|
actions?: ButtonProps[]
|
|
13
22
|
/**
|
|
14
23
|
* Display a close button to dismiss the toast.
|
|
15
24
|
* @default true
|
|
16
25
|
*/
|
|
17
26
|
close?: ButtonProps | boolean
|
|
18
|
-
/** @default
|
|
27
|
+
/** @default app.icons.close */
|
|
19
28
|
closeIcon?: string
|
|
20
29
|
}
|
|
21
30
|
|
|
@@ -39,6 +48,7 @@ import { useTheme } from '../composables/useTheme'
|
|
|
39
48
|
import Button from './Button.vue'
|
|
40
49
|
|
|
41
50
|
const props = withDefaults(defineProps<ToastProps>(), {
|
|
51
|
+
orientation: 'vertical',
|
|
42
52
|
close: true,
|
|
43
53
|
})
|
|
44
54
|
|
|
@@ -50,12 +60,13 @@ const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultOpen',
|
|
|
50
60
|
const el = ref<InstanceType<typeof ToastRoot>>()
|
|
51
61
|
const { height } = useElementBounding(() => el.value?.$el.getBoundingClientRect ? el.value.$el : undefined)
|
|
52
62
|
|
|
53
|
-
const multiline = computed(() => !!props.title && !!props.description)
|
|
54
|
-
|
|
55
63
|
const { theme, createStyler } = useTheme()
|
|
56
64
|
const style = computed(() => {
|
|
57
65
|
const styler = createStyler(theme.value.toast)
|
|
58
|
-
return styler({
|
|
66
|
+
return styler({
|
|
67
|
+
...props,
|
|
68
|
+
title: !!(props.title || slots.title),
|
|
69
|
+
})
|
|
59
70
|
})
|
|
60
71
|
|
|
61
72
|
defineExpose({
|
|
@@ -68,7 +79,7 @@ defineExpose({
|
|
|
68
79
|
ref="el"
|
|
69
80
|
v-slot="{ remaining, duration }"
|
|
70
81
|
v-bind="rootProps"
|
|
71
|
-
:class="style.root({ class: [props.class, props.ui?.root]
|
|
82
|
+
:class="style.root({ class: [props.class, props.ui?.root] })"
|
|
72
83
|
:style="{ '--height': height }"
|
|
73
84
|
>
|
|
74
85
|
<slot name="icon">
|
|
@@ -87,7 +98,7 @@ defineExpose({
|
|
|
87
98
|
</slot>
|
|
88
99
|
</ToastDescription>
|
|
89
100
|
|
|
90
|
-
<div v-if="
|
|
101
|
+
<div v-if="props.orientation === 'vertical' && actions?.length" :class="style.actions({ class: props.ui?.actions })">
|
|
91
102
|
<slot name="actions">
|
|
92
103
|
<ToastAction v-for="(action, index) in props.actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
|
|
93
104
|
<Button size="xs" v-bind="action" />
|
|
@@ -96,8 +107,8 @@ defineExpose({
|
|
|
96
107
|
</div>
|
|
97
108
|
</div>
|
|
98
109
|
|
|
99
|
-
<div v-if="(
|
|
100
|
-
<template v-if="
|
|
110
|
+
<div v-if="(props.orientation === 'horizontal' && actions?.length) || props.close !== null" :class="style.actions({ class: props.ui?.actions })">
|
|
111
|
+
<template v-if="props.orientation === 'horizontal'">
|
|
101
112
|
<slot name="actions">
|
|
102
113
|
<ToastAction v-for="(action, index) in props.actions" :key="index" :alt-text="action.label || 'Action'" as-child @click.stop>
|
|
103
114
|
<Button size="xs" v-bind="action" />
|
|
@@ -107,7 +118,7 @@ defineExpose({
|
|
|
107
118
|
|
|
108
119
|
<ToastClose as-child>
|
|
109
120
|
<slot name="close" :ui="ui">
|
|
110
|
-
<
|
|
121
|
+
<Button
|
|
111
122
|
v-if="props.close"
|
|
112
123
|
:icon="props.closeIcon || theme.app.icons.close"
|
|
113
124
|
size="md"
|
|
@@ -72,6 +72,7 @@ const style = computed(() => {
|
|
|
72
72
|
return styler({
|
|
73
73
|
...props,
|
|
74
74
|
swipeDirection: swipeDirection.value,
|
|
75
|
+
clickable: false,
|
|
75
76
|
})
|
|
76
77
|
})
|
|
77
78
|
|
|
@@ -114,11 +115,9 @@ function getOffset(index: number) {
|
|
|
114
115
|
'--translate': expanded ? 'calc(var(--offset) * var(--translate-factor))' : 'calc(var(--before) * var(--gap))',
|
|
115
116
|
'--transform': 'translateY(var(--translate)) scale(var(--scale))',
|
|
116
117
|
}"
|
|
117
|
-
:class="
|
|
118
|
-
'cursor-pointer': !!toast.click,
|
|
119
|
-
}]"
|
|
118
|
+
:class="style.base({ clickable: !!(toast.onClick) })"
|
|
120
119
|
@update:open="onUpdateOpen($event, toast.id)"
|
|
121
|
-
@click="toast.
|
|
120
|
+
@click="toast.onClick && toast.onClick(toast)"
|
|
122
121
|
/>
|
|
123
122
|
|
|
124
123
|
<ToastPortal :disabled="!portal">
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
|
+
import type { ButtonGroupProps } from '../components/ButtonGroup.vue';
|
|
3
|
+
interface ButtonGroupInjectData {
|
|
4
|
+
size: ButtonGroupProps['size'];
|
|
5
|
+
orientation: ButtonGroupProps['orientation'];
|
|
6
|
+
}
|
|
7
|
+
export declare const InjectionKeyButtonGroup: import("vue").InjectionKey<ComputedRef<ButtonGroupInjectData>>, injectButtonGroup: () => ComputedRef<ButtonGroupInjectData> | undefined, provideButtonGroup: (value: ComputedRef<ButtonGroupInjectData>) => void;
|
|
8
|
+
type UseButtonGroupProps = Pick<ButtonGroupProps, 'size'>;
|
|
9
|
+
export declare function useButtonGroup(props?: UseButtonGroupProps): {
|
|
10
|
+
size: ComputedRef<any>;
|
|
11
|
+
orientation: ComputedRef<any>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { defineInjection } from "./defineInjection.mjs";
|
|
3
|
+
export const {
|
|
4
|
+
InjectionKey: InjectionKeyButtonGroup,
|
|
5
|
+
inject: injectButtonGroup,
|
|
6
|
+
provide: provideButtonGroup
|
|
7
|
+
} = defineInjection("ui.buttonGroup");
|
|
8
|
+
export function useButtonGroup(props = {}) {
|
|
9
|
+
const buttonGroup = injectButtonGroup();
|
|
10
|
+
return {
|
|
11
|
+
size: computed(() => props.size ?? buttonGroup?.value.size),
|
|
12
|
+
orientation: computed(() => buttonGroup?.value.orientation)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { UserConfig } from 'unocss';
|
|
1
|
+
import type { UserConfig } from '@unocss/core';
|
|
2
2
|
import type { MaybeRefOrGetter } from 'vue';
|
|
3
3
|
import * as theme from '../theme';
|
|
4
4
|
export declare const InjectionKeyThemeExtension: import("vue").InjectionKey<MaybeRefOrGetter<import("../types").PartialTheme<typeof theme>>>, provideThemeExtension: (value: MaybeRefOrGetter<import("../types").PartialTheme<typeof theme>>) => void, injectThemeExtension: () => MaybeRefOrGetter<import("../types").PartialTheme<typeof theme>>;
|
|
5
5
|
export declare const InjectionKeyUnoConfig: import("vue").InjectionKey<UserConfig<object>>, provideUnoConfig: (value: UserConfig<object>) => void, injectUnoConfig: () => UserConfig<object>;
|
|
6
6
|
export declare const useTheme: () => {
|
|
7
7
|
theme: import("vue").ComputedRef<typeof theme>;
|
|
8
|
-
createStyler: <V extends import("@byyuurin/ui-kit/index").CVVariants<S, B>, CV extends import("@byyuurin/ui-kit/index").CVCompoundVariants<V, S, B>, B extends import("@byyuurin/ui-kit/index").ClassValue = undefined, S extends import("@byyuurin/ui-kit/index").CVSlots = undefined>(theme: import("@byyuurin/ui-kit/index").CVMeta<V, CV,
|
|
8
|
+
createStyler: <V extends import("@byyuurin/ui-kit/index").CVVariants<S, B>, CV extends import("@byyuurin/ui-kit/index").CVCompoundVariants<V, S, B>, DV extends import("@byyuurin/ui-kit/index").CVDefaultVariants<V, S>, B extends import("@byyuurin/ui-kit/index").ClassValue = undefined, S extends import("@byyuurin/ui-kit/index").CVSlots = undefined>(theme: import("@byyuurin/ui-kit/index").CVMeta<V, CV, DV, B, S>) => [keyof V] extends string[] ? (props: import("@byyuurin/ui-kit/index").VariantProps<import("@byyuurin/ui-kit/index").CVReturnType<V, S, B>> & import("../types").StylerBaseProps) => S extends undefined ? string : { [K in keyof S | (B extends undefined ? never : "base")]: import("@byyuurin/ui-kit/index").CVHandler<V, S, string>; } : (props?: import("../types").StylerBaseProps) => S extends undefined ? string : { [K in keyof S | (B extends undefined ? never : "base")]: import("@byyuurin/ui-kit/index").CVHandler<V, S, string>; };
|
|
9
9
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ToastProps } from '
|
|
1
|
+
import type { ToastProps } from '../types';
|
|
2
2
|
export interface Toast extends Omit<ToastProps, 'defaultOpen'> {
|
|
3
3
|
id: string | number;
|
|
4
|
-
|
|
4
|
+
onClick?: (toast: Toast) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare const useToast: () => {
|
|
7
7
|
toasts: import("vue").Ref<{
|
|
@@ -9,13 +9,13 @@ export declare const useToast: () => {
|
|
|
9
9
|
[x: number]: any;
|
|
10
10
|
[x: symbol]: ToastProps;
|
|
11
11
|
id: string | number;
|
|
12
|
-
|
|
12
|
+
onClick?: ((toast: Toast) => void) | undefined;
|
|
13
13
|
}[], Toast[] | {
|
|
14
14
|
[x: string]: any;
|
|
15
15
|
[x: number]: any;
|
|
16
16
|
[x: symbol]: ToastProps;
|
|
17
17
|
id: string | number;
|
|
18
|
-
|
|
18
|
+
onClick?: ((toast: Toast) => void) | undefined;
|
|
19
19
|
}[]>;
|
|
20
20
|
add: (toast: Partial<Toast>) => Toast;
|
|
21
21
|
update: (id: string | number, toast: Partial<Omit<Toast, "id">>) => void;
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import { createSharedComposable } from "@vueuse/core";
|
|
2
|
-
import { ref } from "vue";
|
|
2
|
+
import { nextTick, ref } from "vue";
|
|
3
3
|
export const useToast = createSharedComposable(() => {
|
|
4
4
|
const toasts = ref([]);
|
|
5
|
+
const running = ref(false);
|
|
6
|
+
const maxToasts = 5;
|
|
7
|
+
const queue = [];
|
|
8
|
+
const generateId = () => `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
9
|
+
async function processQueue() {
|
|
10
|
+
if (running.value || queue.length === 0)
|
|
11
|
+
return;
|
|
12
|
+
running.value = true;
|
|
13
|
+
while (queue.length > 0) {
|
|
14
|
+
const toast = queue.shift();
|
|
15
|
+
await nextTick();
|
|
16
|
+
toasts.value = [...toasts.value, toast].slice(-maxToasts);
|
|
17
|
+
}
|
|
18
|
+
running.value = false;
|
|
19
|
+
}
|
|
5
20
|
function add(toast) {
|
|
6
21
|
const body = {
|
|
7
|
-
id:
|
|
22
|
+
id: generateId(),
|
|
8
23
|
open: true,
|
|
9
24
|
...toast
|
|
10
25
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
toasts.value.push(body);
|
|
14
|
-
toasts.value = toasts.value.slice(-5);
|
|
26
|
+
queue.push(body);
|
|
27
|
+
processQueue();
|
|
15
28
|
return body;
|
|
16
29
|
}
|
|
17
30
|
function update(id, toast) {
|
|
@@ -35,5 +35,22 @@ declare const _default: {
|
|
|
35
35
|
trailingIcon: string;
|
|
36
36
|
label: string;
|
|
37
37
|
}, undefined>;
|
|
38
|
+
defaultVariants: import("@byyuurin/ui-kit/index").CVDefaultVariants<{
|
|
39
|
+
disabled: {
|
|
40
|
+
true: {
|
|
41
|
+
trigger: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}, {
|
|
45
|
+
root: string;
|
|
46
|
+
item: string;
|
|
47
|
+
header: string;
|
|
48
|
+
trigger: string;
|
|
49
|
+
content: string[];
|
|
50
|
+
body: string;
|
|
51
|
+
icon: string;
|
|
52
|
+
trailingIcon: string;
|
|
53
|
+
label: string;
|
|
54
|
+
}>;
|
|
38
55
|
};
|
|
39
56
|
export default _default;
|
|
@@ -81,5 +81,45 @@ declare const _default: {
|
|
|
81
81
|
actions: string;
|
|
82
82
|
close: string;
|
|
83
83
|
}, undefined>;
|
|
84
|
+
defaultVariants: import("@byyuurin/ui-kit/index").CVDefaultVariants<{
|
|
85
|
+
variant: {
|
|
86
|
+
solid: {
|
|
87
|
+
root: string;
|
|
88
|
+
close: string;
|
|
89
|
+
};
|
|
90
|
+
outline: {
|
|
91
|
+
root: string;
|
|
92
|
+
};
|
|
93
|
+
soft: {
|
|
94
|
+
root: string;
|
|
95
|
+
};
|
|
96
|
+
'soft-outline': {
|
|
97
|
+
root: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
orientation: {
|
|
101
|
+
horizontal: {
|
|
102
|
+
root: string;
|
|
103
|
+
actions: string;
|
|
104
|
+
};
|
|
105
|
+
vertical: {
|
|
106
|
+
root: string;
|
|
107
|
+
actions: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
title: {
|
|
111
|
+
true: {
|
|
112
|
+
description: string;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
}, {
|
|
116
|
+
root: string;
|
|
117
|
+
wrapper: string;
|
|
118
|
+
title: string;
|
|
119
|
+
description: string;
|
|
120
|
+
icon: string;
|
|
121
|
+
actions: string;
|
|
122
|
+
close: string;
|
|
123
|
+
}>;
|
|
84
124
|
};
|
|
85
125
|
export default _default;
|
|
@@ -14,17 +14,17 @@ export default ct(
|
|
|
14
14
|
variants: {
|
|
15
15
|
variant: {
|
|
16
16
|
"solid": {
|
|
17
|
-
root: "color-ui-c1 bg-ui-fill",
|
|
17
|
+
root: "color-ui-c1 bg-solid-ui-fill",
|
|
18
18
|
close: "ui-base-inverted"
|
|
19
19
|
},
|
|
20
20
|
"outline": {
|
|
21
|
-
root: "color-ui-content bg-ui-c1 ring ring-inset ring-ui-fill"
|
|
21
|
+
root: "color-ui-content bg-solid-ui-c1 ring ring-inset ring-ui-fill"
|
|
22
22
|
},
|
|
23
23
|
"soft": {
|
|
24
|
-
root: "color-ui-content bg-ui-fill/10"
|
|
24
|
+
root: "color-ui-content bg-solid-ui-fill/10"
|
|
25
25
|
},
|
|
26
26
|
"soft-outline": {
|
|
27
|
-
root: "color-ui-content bg-ui-fill/10 ring ring-inset ring-ui-fill/40"
|
|
27
|
+
root: "color-ui-content bg-solid-ui-fill/10 ring ring-inset ring-ui-fill/40"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
orientation: {
|
|
@@ -5,6 +5,11 @@ export default {
|
|
|
5
5
|
loading: "i-mdi-loading",
|
|
6
6
|
check: "i-mdi-check-bold",
|
|
7
7
|
indeterminate: "i-mdi-minus-thick",
|
|
8
|
-
down: "i-mdi-chevron-down"
|
|
8
|
+
down: "i-mdi-chevron-down",
|
|
9
|
+
arrowLeft: "i-mdi-chevron-left",
|
|
10
|
+
arrowRight: "i-mdi-chevron-right",
|
|
11
|
+
doubleLeft: "i-mdi-chevron-double-left",
|
|
12
|
+
doubleRight: "i-mdi-chevron-double-right",
|
|
13
|
+
ellipsis: "i-mdi-dots-horizontal"
|
|
9
14
|
}
|
|
10
15
|
};
|
|
@@ -6,7 +6,7 @@ export default ct(
|
|
|
6
6
|
root: "relative inline-flex items-center justify-center shrink-0",
|
|
7
7
|
base: [
|
|
8
8
|
"inline-block rounded-full ring ring-ui-c1 flex items-center justify-center color-ui-c1 font-medium whitespace-nowrap",
|
|
9
|
-
"h-1.2em min-w-1.2em p-0.2em text-0.8em bg-ui-fill"
|
|
9
|
+
"h-1.2em min-w-1.2em p-0.2em text-0.8em bg-solid-ui-fill"
|
|
10
10
|
]
|
|
11
11
|
},
|
|
12
12
|
variants: {
|
|
@@ -84,6 +84,9 @@ export default ct(
|
|
|
84
84
|
base: "translate-y-1/2 -translate-x-1/2 transform"
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
]
|
|
87
|
+
],
|
|
88
|
+
defaultVariants: {
|
|
89
|
+
size: "md"
|
|
90
|
+
}
|
|
88
91
|
}
|
|
89
92
|
);
|