@byyuurin/ui 0.0.6 → 0.0.7
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 +4 -5
- package/dist/module.cjs +5 -0
- package/dist/module.json +12 -0
- package/dist/{nuxt.mjs → module.mjs} +4 -4
- package/dist/module.mjs.map +1 -0
- package/dist/runtime/components/Accordion.vue +20 -31
- package/dist/runtime/components/Alert.vue +1 -1
- package/dist/runtime/components/Button.vue +10 -11
- package/dist/runtime/components/Card.vue +9 -6
- package/dist/runtime/components/Checkbox.vue +3 -3
- package/dist/runtime/components/Chip.vue +2 -2
- package/dist/runtime/components/Collapsible.vue +56 -0
- package/dist/runtime/components/Drawer.vue +4 -2
- package/dist/runtime/components/Input.vue +4 -4
- package/dist/runtime/components/InputNumber.vue +167 -0
- package/dist/runtime/components/Link.vue +301 -72
- package/dist/runtime/components/LinkBase.vue +88 -0
- package/dist/runtime/components/Modal.vue +0 -1
- package/dist/runtime/components/Select.vue +4 -4
- package/dist/runtime/components/Separator.vue +63 -0
- package/dist/runtime/components/Switch.vue +3 -3
- package/dist/runtime/components/Table.vue +292 -0
- package/dist/runtime/components/Tabs.vue +17 -17
- package/dist/runtime/components/Toast.vue +1 -1
- package/dist/runtime/components/Toaster.vue +1 -35
- package/dist/runtime/composables/useButtonGroup.d.ts +1 -1
- package/dist/runtime/composables/{useButtonGroup.mjs → useButtonGroup.js} +1 -1
- package/dist/runtime/composables/{useComponentIcons.mjs → useComponentIcons.js} +1 -1
- package/dist/runtime/composables/useModal.d.ts +1 -1
- package/dist/runtime/composables/{useModal.mjs → useModal.js} +1 -1
- package/dist/runtime/composables/useTheme.d.ts +3 -3
- package/dist/runtime/composables/{useTheme.mjs → useTheme.js} +3 -3
- package/dist/runtime/composables/useToast.d.ts +1 -1
- package/dist/runtime/index.d.ts +34 -0
- package/dist/runtime/index.js +34 -0
- package/dist/runtime/theme/accordion.d.ts +8 -8
- package/dist/runtime/theme/{accordion.mjs → accordion.js} +2 -2
- package/dist/runtime/theme/alert.d.ts +2 -2
- package/dist/runtime/theme/{alert.mjs → alert.js} +4 -4
- package/dist/runtime/theme/app.d.ts +3 -0
- package/dist/runtime/theme/{app.mjs → app.js} +4 -1
- package/dist/runtime/theme/badge.d.ts +45 -21
- package/dist/runtime/theme/{badge.mjs → badge.js} +2 -2
- package/dist/runtime/theme/button-group.d.ts +2 -2
- package/dist/runtime/theme/button.d.ts +57 -111
- package/dist/runtime/theme/button.js +164 -0
- package/dist/runtime/theme/card.d.ts +38 -38
- package/dist/runtime/theme/card.js +37 -0
- package/dist/runtime/theme/carousel.d.ts +2 -2
- package/dist/runtime/theme/{carousel.mjs → carousel.js} +2 -2
- package/dist/runtime/theme/checkbox.d.ts +1 -1
- package/dist/runtime/theme/{checkbox.mjs → checkbox.js} +3 -3
- package/dist/runtime/theme/chip.d.ts +45 -12
- package/dist/runtime/theme/{chip.mjs → chip.js} +5 -7
- package/dist/runtime/theme/collapsible.d.ts +38 -0
- package/dist/runtime/theme/collapsible.js +10 -0
- package/dist/runtime/theme/drawer.d.ts +43 -43
- package/dist/runtime/theme/{drawer.mjs → drawer.js} +33 -22
- package/dist/runtime/theme/index.d.ts +31 -27
- package/dist/runtime/theme/index.js +31 -0
- package/dist/runtime/theme/input-number.d.ts +135 -0
- package/dist/runtime/theme/input-number.js +92 -0
- package/dist/runtime/theme/input.d.ts +71 -99
- package/dist/runtime/theme/{input.mjs → input.js} +14 -14
- package/dist/runtime/theme/link.d.ts +2 -2
- package/dist/runtime/theme/{link.mjs → link.js} +1 -1
- package/dist/runtime/theme/modal.d.ts +31 -8
- package/dist/runtime/theme/{modal.mjs → modal.js} +4 -9
- package/dist/runtime/theme/pagination.d.ts +17 -17
- package/dist/runtime/theme/pinInput.d.ts +42 -42
- package/dist/runtime/theme/{pinInput.mjs → pinInput.js} +10 -10
- package/dist/runtime/theme/popover.d.ts +8 -8
- package/dist/runtime/theme/{popover.mjs → popover.js} +1 -1
- package/dist/runtime/theme/radio-group.d.ts +1 -1
- package/dist/runtime/theme/{radio-group.mjs → radio-group.js} +1 -1
- package/dist/runtime/theme/scroll-area.d.ts +17 -17
- package/dist/runtime/theme/{scroll-area.mjs → scroll-area.js} +2 -2
- package/dist/runtime/theme/select.d.ts +84 -99
- package/dist/runtime/theme/{select.mjs → select.js} +17 -17
- package/dist/runtime/theme/separator.d.ts +95 -0
- package/dist/runtime/theme/separator.js +53 -0
- package/dist/runtime/theme/slider.d.ts +1 -1
- package/dist/runtime/theme/{slider.mjs → slider.js} +3 -3
- package/dist/runtime/theme/switch.d.ts +1 -1
- package/dist/runtime/theme/{switch.mjs → switch.js} +2 -2
- package/dist/runtime/theme/table.d.ts +89 -0
- package/dist/runtime/theme/table.js +35 -0
- package/dist/runtime/theme/tabs.d.ts +69 -52
- package/dist/runtime/theme/{tabs.mjs → tabs.js} +11 -11
- package/dist/runtime/theme/textarea.d.ts +43 -37
- package/dist/runtime/theme/{textarea.mjs → textarea.js} +10 -10
- package/dist/runtime/theme/toast.d.ts +2 -2
- package/dist/runtime/theme/{toast.mjs → toast.js} +1 -1
- package/dist/runtime/theme/toaster.d.ts +42 -27
- package/dist/runtime/theme/tooltip.d.ts +11 -11
- package/dist/runtime/theme/tooltip.js +11 -0
- package/dist/runtime/types/components.d.ts +31 -27
- package/dist/runtime/types/index.d.ts +4 -4
- package/dist/runtime/types/index.js +2 -0
- package/dist/runtime/types/utils.js +0 -0
- package/dist/runtime/utils/index.d.ts +3 -3
- package/dist/runtime/utils/{index.mjs → index.js} +3 -3
- package/dist/runtime/utils/link.d.ts +22 -7
- package/dist/runtime/utils/link.js +30 -0
- package/dist/runtime/utils/styler.d.ts +1 -1
- package/dist/runtime/vue/stubs.d.ts +9 -0
- package/dist/runtime/vue/stubs.js +16 -0
- package/dist/shared/{ui.D4zm1r0C.mjs → ui.d1728164.mjs} +1 -1
- package/dist/shared/ui.d1728164.mjs.map +1 -0
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/unocss.d.mts +6 -11
- package/dist/unocss.d.ts +6 -11
- package/dist/unocss.mjs +40 -21
- package/dist/unocss.mjs.map +1 -1
- package/dist/unplugin.mjs +37 -1
- package/dist/unplugin.mjs.map +1 -1
- package/dist/vite.d.mts +0 -1
- package/dist/vite.d.ts +0 -1
- package/dist/vite.mjs +3 -1
- package/dist/vite.mjs.map +1 -1
- package/package.json +37 -36
- package/dist/index.d.ts +0 -29
- package/dist/index.mjs +0 -29
- package/dist/nuxt.mjs.map +0 -1
- package/dist/runtime/theme/button.mjs +0 -148
- package/dist/runtime/theme/card.mjs +0 -14
- package/dist/runtime/theme/index.mjs +0 -27
- package/dist/runtime/theme/tooltip.mjs +0 -11
- package/dist/runtime/types/components.mjs +0 -27
- package/dist/runtime/types/index.mjs +0 -2
- package/dist/runtime/utils/link.mjs +0 -4
- package/dist/shared/ui.D4zm1r0C.mjs.map +0 -1
- /package/dist/{nuxt.d.mts → module.d.mts} +0 -0
- /package/dist/{nuxt.d.ts → module.d.ts} +0 -0
- /package/dist/runtime/composables/{defineInjection.mjs → defineInjection.js} +0 -0
- /package/dist/runtime/composables/{useToast.mjs → useToast.js} +0 -0
- /package/dist/runtime/theme/{button-group.mjs → button-group.js} +0 -0
- /package/dist/runtime/theme/{pagination.mjs → pagination.js} +0 -0
- /package/dist/runtime/theme/{toaster.mjs → toaster.js} +0 -0
- /package/dist/runtime/types/{utils.mjs → components.js} +0 -0
- /package/dist/runtime/utils/{extend-theme.mjs → extend-theme.js} +0 -0
- /package/dist/runtime/utils/{styler.mjs → styler.js} +0 -0
|
@@ -1,117 +1,346 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { PrimitiveProps } from 'reka-ui'
|
|
3
|
+
import type { ButtonHTMLAttributes } from 'vue'
|
|
4
|
+
import type { RouteLocationRaw, RouterLinkProps } from 'vue-router'
|
|
3
5
|
import type { link } from '../theme'
|
|
4
|
-
import type { ComponentAttrs
|
|
6
|
+
import type { ComponentAttrs } from '../types'
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
interface NuxtLinkProps extends Omit<RouterLinkProps, 'to'> {
|
|
9
|
+
/**
|
|
10
|
+
* Route Location the link should navigate to when clicked on.
|
|
11
|
+
*/
|
|
12
|
+
to?: RouteLocationRaw // need to manually type to avoid breaking typedPages
|
|
13
|
+
/**
|
|
14
|
+
* An alias for `to`. If used with `to`, `href` will be ignored
|
|
15
|
+
*/
|
|
16
|
+
href?: NuxtLinkProps['to']
|
|
17
|
+
/**
|
|
18
|
+
* Forces the link to be considered as external (true) or internal (false). This is helpful to handle edge-cases
|
|
19
|
+
*/
|
|
20
|
+
external?: boolean
|
|
21
|
+
/**
|
|
22
|
+
* Where to display the linked URL, as the name for a browsing context.
|
|
23
|
+
*/
|
|
24
|
+
target?: '_blank' | '_parent' | '_self' | '_top' | (string & {}) | null
|
|
25
|
+
/**
|
|
26
|
+
* A rel attribute value to apply on the link. Defaults to "noopener noreferrer" for external links.
|
|
27
|
+
*/
|
|
28
|
+
rel?: 'noopener' | 'noreferrer' | 'nofollow' | 'sponsored' | 'ugc' | (string & {}) | null
|
|
29
|
+
/**
|
|
30
|
+
* If set to true, no rel attribute will be added to the link
|
|
31
|
+
*/
|
|
32
|
+
noRel?: boolean
|
|
33
|
+
/**
|
|
34
|
+
* A class to apply to links that have been prefetched.
|
|
35
|
+
*/
|
|
36
|
+
prefetchedClass?: string
|
|
37
|
+
/**
|
|
38
|
+
* When enabled will prefetch middleware, layouts and payloads of links in the viewport.
|
|
39
|
+
*/
|
|
40
|
+
prefetch?: boolean
|
|
41
|
+
/**
|
|
42
|
+
* Allows controlling when to prefetch links. By default, prefetch is triggered only on visibility.
|
|
43
|
+
*/
|
|
44
|
+
prefetchOn?: 'visibility' | 'interaction' | Partial<{
|
|
45
|
+
visibility: boolean
|
|
46
|
+
interaction: boolean
|
|
47
|
+
}>
|
|
48
|
+
/**
|
|
49
|
+
* Escape hatch to disable `prefetch` attribute.
|
|
50
|
+
*/
|
|
51
|
+
noPrefetch?: boolean
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface LinkProps extends Omit<ComponentAttrs<typeof link>, 'ui'>, NuxtLinkProps {
|
|
55
|
+
/**
|
|
56
|
+
* The element or component this component should render as when not a link.
|
|
57
|
+
* @default 'button'
|
|
58
|
+
*/
|
|
7
59
|
as?: PrimitiveProps['as']
|
|
8
|
-
|
|
9
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The type of the button when not a link.
|
|
62
|
+
* @default 'button'
|
|
63
|
+
*/
|
|
64
|
+
type?: ButtonHTMLAttributes['type']
|
|
10
65
|
label?: string
|
|
11
|
-
href?: string
|
|
12
|
-
navigate?: (e: MouseEvent) => void
|
|
13
|
-
/** A rel attribute value to apply on the link. */
|
|
14
|
-
rel?: HintString<'noopener' | 'noreferrer' | 'nofollow' | 'sponsored' | 'ugc'> | null
|
|
15
|
-
noRel?: boolean
|
|
16
|
-
/** Where to display the linked URL, as the name for a browsing context. */
|
|
17
|
-
target?: HintString<'_blank' | '_parent' | '_self' | '_top'> | null
|
|
18
|
-
isExternal?: boolean
|
|
19
|
-
underline?: boolean
|
|
20
|
-
active?: boolean
|
|
21
66
|
disabled?: boolean
|
|
67
|
+
/** Force the link to be active independent of the current route. */
|
|
68
|
+
active?: boolean
|
|
69
|
+
/** Will only be active if the current route is an exact match. */
|
|
70
|
+
exact?: boolean
|
|
71
|
+
/** Will only be active if the current route query is an exact match. */
|
|
72
|
+
exactQuery?: boolean | 'partial'
|
|
73
|
+
/** Will only be active if the current route hash is an exact match. */
|
|
74
|
+
exactHash?: boolean
|
|
75
|
+
/** The class to apply when the link is inactive. */
|
|
76
|
+
inactiveClass?: string
|
|
77
|
+
/** The class to apply when the link is disabled. */
|
|
78
|
+
disableClass?: string
|
|
79
|
+
custom?: boolean
|
|
80
|
+
underline?: boolean
|
|
22
81
|
/** When `true`, only styles from `class`, `ui.active`, and `ui.inactive` will be applied. */
|
|
23
82
|
raw?: boolean
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface LinkSlots {
|
|
86
|
+
default?: (props: { active: boolean }) => any
|
|
29
87
|
}
|
|
30
88
|
</script>
|
|
31
89
|
|
|
32
90
|
<script setup lang="ts">
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
91
|
+
import { reactiveOmit } from '@vueuse/core'
|
|
92
|
+
import { diff, isEqual } from 'ohash/utils'
|
|
93
|
+
import { useForwardProps } from 'reka-ui'
|
|
94
|
+
import { hasProtocol } from 'ufo'
|
|
95
|
+
import { computed, getCurrentInstance, resolveComponent } from 'vue'
|
|
96
|
+
import { useNuxtApp, useRoute } from '#imports'
|
|
35
97
|
import { useTheme } from '../composables/useTheme'
|
|
98
|
+
import LinkBase from './LinkBase.vue'
|
|
99
|
+
|
|
100
|
+
defineOptions({ inheritAttrs: false })
|
|
36
101
|
|
|
37
102
|
const props = withDefaults(defineProps<LinkProps>(), {
|
|
38
103
|
as: 'button',
|
|
39
104
|
type: 'button',
|
|
40
105
|
})
|
|
106
|
+
defineSlots<LinkSlots>()
|
|
107
|
+
|
|
108
|
+
// Check if vue-router is available by checking for the injection key
|
|
109
|
+
const hasRouter = computed(() => {
|
|
110
|
+
const app = getCurrentInstance()?.appContext.app
|
|
111
|
+
return !!(app?.config?.globalProperties?.$router)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
const nuxtApp = useNuxtApp()
|
|
115
|
+
const hasNuxtLink = !!nuxtApp.$router
|
|
116
|
+
|
|
117
|
+
const linkComponent = computed(() => ({
|
|
118
|
+
NuxtLink: nuxtApp.$router ? resolveComponent('NuxtLink') : null,
|
|
119
|
+
RouterLink: hasRouter.value ? resolveComponent('RouterLink') : null,
|
|
120
|
+
}))
|
|
121
|
+
|
|
122
|
+
// Only try to get route if router exists
|
|
123
|
+
const route = computed(() => {
|
|
124
|
+
if (!hasRouter.value)
|
|
125
|
+
return null
|
|
41
126
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const base = { as, rel, target }
|
|
45
|
-
|
|
46
|
-
if (href) {
|
|
47
|
-
return {
|
|
48
|
-
...base,
|
|
49
|
-
'as': 'a',
|
|
50
|
-
'href': disabled ? undefined : href,
|
|
51
|
-
'aria-disabled': disabled ? 'true' : undefined,
|
|
52
|
-
'role': disabled ? 'link' : undefined,
|
|
53
|
-
'tabindex': disabled ? -1 : undefined,
|
|
54
|
-
}
|
|
127
|
+
try {
|
|
128
|
+
return useRoute()
|
|
55
129
|
}
|
|
130
|
+
catch {
|
|
131
|
+
return null
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const linkProps = useForwardProps(reactiveOmit(
|
|
136
|
+
props,
|
|
137
|
+
'as',
|
|
138
|
+
'type',
|
|
139
|
+
'disabled',
|
|
140
|
+
'active',
|
|
141
|
+
'exact',
|
|
142
|
+
'exactQuery',
|
|
143
|
+
'exactHash',
|
|
144
|
+
'activeClass',
|
|
145
|
+
'inactiveClass',
|
|
146
|
+
'raw',
|
|
147
|
+
'class',
|
|
148
|
+
...(hasNuxtLink ? [] : ['to'] as const),
|
|
149
|
+
))
|
|
150
|
+
|
|
151
|
+
function isPartiallyEqual(item1: any, item2: any) {
|
|
152
|
+
const diffedKeys = diff(item1, item2).reduce((filtered, q) => {
|
|
153
|
+
if (q.type === 'added')
|
|
154
|
+
filtered.add(q.key)
|
|
155
|
+
|
|
156
|
+
return filtered
|
|
157
|
+
}, new Set<string>())
|
|
56
158
|
|
|
57
|
-
|
|
58
|
-
|
|
159
|
+
const item1Filtered = Object.fromEntries(Object.entries(item1).filter(([key]) => !diffedKeys.has(key)))
|
|
160
|
+
const item2Filtered = Object.fromEntries(Object.entries(item2).filter(([key]) => !diffedKeys.has(key)))
|
|
59
161
|
|
|
60
|
-
return
|
|
162
|
+
return isEqual(item1Filtered, item2Filtered)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const isExternalLink = computed(() => {
|
|
166
|
+
if (!props.to)
|
|
167
|
+
return false
|
|
168
|
+
|
|
169
|
+
return typeof props.to === 'string' && hasProtocol(props.to, { acceptRelative: true })
|
|
61
170
|
})
|
|
62
171
|
|
|
63
|
-
|
|
172
|
+
function isLinkActive({ route: linkRoute, isActive, isExactActive }: any) {
|
|
173
|
+
if (props.active !== undefined)
|
|
174
|
+
return props.active
|
|
64
175
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
176
|
+
if (props.exactQuery === 'partial') {
|
|
177
|
+
if (!isPartiallyEqual(linkRoute?.query, route.value?.query))
|
|
178
|
+
return false
|
|
179
|
+
}
|
|
180
|
+
else if (props.exactQuery === true && !isEqual(linkRoute?.query, route.value?.query)) {
|
|
181
|
+
return false
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (props.exactHash && linkRoute?.hash !== route.value?.hash)
|
|
185
|
+
return false
|
|
186
|
+
|
|
187
|
+
if (props.exact && isExactActive)
|
|
188
|
+
return true
|
|
68
189
|
|
|
190
|
+
if (!props.exact && isActive)
|
|
191
|
+
return true
|
|
192
|
+
|
|
193
|
+
return false
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const { theme, createStyler } = useTheme()
|
|
197
|
+
|
|
198
|
+
function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
|
|
69
199
|
const { link } = theme.value
|
|
200
|
+
const active = isLinkActive({ route, isActive, isExactActive })
|
|
201
|
+
|
|
202
|
+
if (props.raw)
|
|
203
|
+
return [props.class, active ? props.activeClass : props.inactiveClass]
|
|
70
204
|
|
|
71
205
|
const styler = createStyler({
|
|
72
206
|
...link,
|
|
73
207
|
variants: {
|
|
74
208
|
...link.variants,
|
|
75
209
|
active: {
|
|
76
|
-
true: [link.variants.active.true, props.
|
|
77
|
-
false: [link.variants.active.false, props.
|
|
210
|
+
true: [link.variants.active.true, props.activeClass],
|
|
211
|
+
false: [link.variants.active.false, props.inactiveClass],
|
|
78
212
|
},
|
|
79
213
|
disabled: {
|
|
80
|
-
true: [link.variants.disabled.true, props.
|
|
214
|
+
true: [link.variants.disabled.true, props.disableClass],
|
|
81
215
|
},
|
|
82
216
|
},
|
|
83
217
|
})
|
|
84
|
-
return styler(props)
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
function handleClick(e: MouseEvent) {
|
|
88
|
-
if (props.disabled) {
|
|
89
|
-
e.stopPropagation()
|
|
90
|
-
e.preventDefault()
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (props.onClick) {
|
|
95
|
-
const handlers = Array.isArray(props.onClick) ? props.onClick : [props.onClick]
|
|
96
|
-
for (const handler of handlers)
|
|
97
|
-
handler(e)
|
|
98
|
-
}
|
|
99
218
|
|
|
100
|
-
|
|
101
|
-
props.navigate(e)
|
|
219
|
+
return styler({ ...props, active })
|
|
102
220
|
}
|
|
103
221
|
</script>
|
|
104
222
|
|
|
105
223
|
<template>
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
224
|
+
<template v-if="hasRouter">
|
|
225
|
+
<component
|
|
226
|
+
:is="linkComponent.NuxtLink"
|
|
227
|
+
v-if="hasNuxtLink"
|
|
228
|
+
v-slot="{ href, navigate, route: linkRoute, rel, target, isExternal, isActive, isExactActive }"
|
|
229
|
+
v-bind="linkProps"
|
|
230
|
+
:href="to ? undefined : href"
|
|
231
|
+
custom
|
|
232
|
+
>
|
|
233
|
+
<template v-if="custom">
|
|
234
|
+
<slot
|
|
235
|
+
v-bind="{
|
|
236
|
+
...$attrs,
|
|
237
|
+
as,
|
|
238
|
+
type,
|
|
239
|
+
disabled,
|
|
240
|
+
href,
|
|
241
|
+
navigate,
|
|
242
|
+
rel,
|
|
243
|
+
target,
|
|
244
|
+
isExternal,
|
|
245
|
+
active: isLinkActive({ route: linkRoute, isActive, isExactActive }),
|
|
246
|
+
}"
|
|
247
|
+
>
|
|
248
|
+
{{ props.label }}
|
|
249
|
+
</slot>
|
|
250
|
+
</template>
|
|
251
|
+
<LinkBase
|
|
252
|
+
v-else
|
|
253
|
+
v-bind="{
|
|
254
|
+
...$attrs,
|
|
255
|
+
as,
|
|
256
|
+
type,
|
|
257
|
+
disabled,
|
|
258
|
+
href,
|
|
259
|
+
navigate,
|
|
260
|
+
rel,
|
|
261
|
+
target,
|
|
262
|
+
isExternal,
|
|
263
|
+
}"
|
|
264
|
+
:class="resolveLinkClass({ route: linkRoute, isActive, isExactActive })"
|
|
265
|
+
>
|
|
266
|
+
<slot :active="isLinkActive({ route: linkRoute, isActive, isExactActive })">
|
|
267
|
+
{{ props.label }}
|
|
268
|
+
</slot>
|
|
269
|
+
</LinkBase>
|
|
270
|
+
</component>
|
|
271
|
+
<component
|
|
272
|
+
:is="linkComponent.RouterLink"
|
|
273
|
+
v-else
|
|
274
|
+
v-slot="{ href, navigate, route: linkRoute, isActive, isExactActive }"
|
|
275
|
+
v-bind="linkProps"
|
|
276
|
+
:to="to || '#'"
|
|
277
|
+
custom
|
|
278
|
+
>
|
|
279
|
+
<template v-if="custom">
|
|
280
|
+
<slot
|
|
281
|
+
v-bind="{
|
|
282
|
+
...$attrs,
|
|
283
|
+
as,
|
|
284
|
+
type,
|
|
285
|
+
disabled,
|
|
286
|
+
href: to ? href : undefined,
|
|
287
|
+
navigate,
|
|
288
|
+
active: isLinkActive({ route: linkRoute, isActive, isExactActive }),
|
|
289
|
+
}"
|
|
290
|
+
>
|
|
291
|
+
{{ props.label }}
|
|
292
|
+
</slot>
|
|
293
|
+
</template>
|
|
294
|
+
<LinkBase
|
|
295
|
+
v-else
|
|
296
|
+
v-bind="{
|
|
297
|
+
...$attrs,
|
|
298
|
+
as,
|
|
299
|
+
type,
|
|
300
|
+
disabled,
|
|
301
|
+
href: to ? href : undefined,
|
|
302
|
+
navigate,
|
|
303
|
+
}"
|
|
304
|
+
:class="resolveLinkClass({ route: linkRoute, isActive, isExactActive })"
|
|
305
|
+
>
|
|
306
|
+
<slot :active="isLinkActive({ route: linkRoute, isActive, isExactActive })">
|
|
307
|
+
{{ props.label }}
|
|
308
|
+
</slot>
|
|
309
|
+
</LinkBase>
|
|
310
|
+
</component>
|
|
311
|
+
</template>
|
|
312
|
+
<template v-else>
|
|
313
|
+
<template v-if="props.custom">
|
|
314
|
+
<slot
|
|
315
|
+
v-bind="{
|
|
316
|
+
...$attrs,
|
|
317
|
+
as,
|
|
318
|
+
type,
|
|
319
|
+
disabled,
|
|
320
|
+
href: to,
|
|
321
|
+
target: isExternalLink ? '_blank' : undefined,
|
|
322
|
+
active: false,
|
|
323
|
+
}"
|
|
324
|
+
>
|
|
325
|
+
{{ props.label }}
|
|
326
|
+
</slot>
|
|
327
|
+
</template>
|
|
328
|
+
<LinkBase
|
|
329
|
+
v-else
|
|
330
|
+
v-bind="{
|
|
331
|
+
...$attrs,
|
|
332
|
+
as,
|
|
333
|
+
type,
|
|
334
|
+
disabled,
|
|
335
|
+
href: (to as string),
|
|
336
|
+
target: isExternalLink ? '_blank' : undefined,
|
|
337
|
+
}"
|
|
338
|
+
:is-external="isExternalLink"
|
|
339
|
+
:class="resolveLinkClass()"
|
|
340
|
+
>
|
|
341
|
+
<slot :active="false">
|
|
342
|
+
{{ props.label }}
|
|
343
|
+
</slot>
|
|
344
|
+
</LinkBase>
|
|
345
|
+
</template>
|
|
117
346
|
</template>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PrimitiveProps } from 'reka-ui'
|
|
3
|
+
|
|
4
|
+
export interface LinkBaseProps {
|
|
5
|
+
/**
|
|
6
|
+
* The element or component this component should render as.
|
|
7
|
+
* @default 'button'
|
|
8
|
+
*/
|
|
9
|
+
as?: PrimitiveProps['as']
|
|
10
|
+
type?: string
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
onClick?: ((e: MouseEvent) => void | Promise<void>) | Array<((e: MouseEvent) => void | Promise<void>)>
|
|
13
|
+
href?: string
|
|
14
|
+
navigate?: (e: MouseEvent) => void
|
|
15
|
+
rel?: string
|
|
16
|
+
target?: string
|
|
17
|
+
isExternal?: boolean
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import { Primitive } from 'reka-ui'
|
|
23
|
+
import { computed } from 'vue'
|
|
24
|
+
|
|
25
|
+
const props = withDefaults(defineProps<LinkBaseProps>(), {
|
|
26
|
+
as: 'button',
|
|
27
|
+
type: 'button',
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const wrapperProps = computed(() => {
|
|
31
|
+
const { href, rel, target, disabled } = props
|
|
32
|
+
|
|
33
|
+
const baseProps = {
|
|
34
|
+
rel,
|
|
35
|
+
target,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (props.href) {
|
|
39
|
+
return {
|
|
40
|
+
...baseProps,
|
|
41
|
+
'as': 'a',
|
|
42
|
+
'href': disabled ? undefined : href,
|
|
43
|
+
'aria-disabled': disabled ? 'true' : undefined,
|
|
44
|
+
'role': disabled ? 'link' : undefined,
|
|
45
|
+
'tabindex': disabled ? -1 : undefined,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (props.as === 'button') {
|
|
50
|
+
return {
|
|
51
|
+
...baseProps,
|
|
52
|
+
as: props.as,
|
|
53
|
+
type: props.type,
|
|
54
|
+
disabled,
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
...baseProps,
|
|
60
|
+
as: props.as,
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
function onClickWrapper(e: MouseEvent) {
|
|
65
|
+
if (props.disabled) {
|
|
66
|
+
e.stopPropagation()
|
|
67
|
+
e.preventDefault()
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (props.onClick) {
|
|
72
|
+
for (const onClick of Array.isArray(props.onClick) ? props.onClick : [props.onClick])
|
|
73
|
+
onClick(e)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (props.href && props.navigate && !props.isExternal)
|
|
77
|
+
props.navigate(e)
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<template>
|
|
82
|
+
<Primitive
|
|
83
|
+
v-bind="wrapperProps"
|
|
84
|
+
@click="onClickWrapper"
|
|
85
|
+
>
|
|
86
|
+
<slot></slot>
|
|
87
|
+
</Primitive>
|
|
88
|
+
</template>
|
|
@@ -198,7 +198,7 @@ function onUpdateOpen(value: boolean) {
|
|
|
198
198
|
<SelectTrigger :id="props.id" :class="style.base({ class: [props.class, props.ui?.base] })">
|
|
199
199
|
<span v-if="isPrefix || slots.prefix" :class="style.prefix({ class: props.ui?.prefix })">
|
|
200
200
|
<slot name="prefix" :model-value="typedValue(innerValue)" :open="open" :ui="props.ui">
|
|
201
|
-
<
|
|
201
|
+
<span v-if="isPrefix && prefixIconName" :class="style.prefixIcon({ class: [prefixIconName, props.ui?.prefixIcon] })"></span>
|
|
202
202
|
</slot>
|
|
203
203
|
</span>
|
|
204
204
|
|
|
@@ -215,7 +215,7 @@ function onUpdateOpen(value: boolean) {
|
|
|
215
215
|
|
|
216
216
|
<span v-if="isSuffix || !!slots.suffix" :class="style.suffix({ class: props.ui?.suffix })">
|
|
217
217
|
<slot name="suffix" :model-value="typedValue(innerValue)" :open="open" :ui="props.ui">
|
|
218
|
-
<
|
|
218
|
+
<span v-if="suffixIconName" :class="style.suffixIcon({ class: [suffixIconName, props.ui?.suffixIcon] })"></span>
|
|
219
219
|
</slot>
|
|
220
220
|
</span>
|
|
221
221
|
</SelectTrigger>
|
|
@@ -238,7 +238,7 @@ function onUpdateOpen(value: boolean) {
|
|
|
238
238
|
>
|
|
239
239
|
<slot name="item" :item="typedItem(item)" :index="index">
|
|
240
240
|
<slot name="itemPrefix" :item="typedItem(item)" :index="index">
|
|
241
|
-
<
|
|
241
|
+
<span v-if="item.icon" :class="style.itemPrefixIcon({ class: [item.icon, props.ui?.itemPrefixIcon] })"></span>
|
|
242
242
|
</slot>
|
|
243
243
|
|
|
244
244
|
<SelectItemText :class="style.itemLabel({ class: props.ui?.itemLabel })">
|
|
@@ -251,7 +251,7 @@ function onUpdateOpen(value: boolean) {
|
|
|
251
251
|
<slot name="itemSuffix" :item="typedItem(item)" :index="index"></slot>
|
|
252
252
|
|
|
253
253
|
<SelectItemIndicator as-child>
|
|
254
|
-
<
|
|
254
|
+
<span :class="style.itemSuffixIcon({ class: [props.selectedIcon || theme.app.icons.check, props.ui?.itemSuffixIcon] })"></span>
|
|
255
255
|
</SelectItemIndicator>
|
|
256
256
|
</span>
|
|
257
257
|
</slot>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
+
import type { SeparatorProps as RekaSeparatorProps } from 'reka-ui'
|
|
4
|
+
import type { separator } from '../theme'
|
|
5
|
+
import type { ComponentAttrs } from '../types'
|
|
6
|
+
|
|
7
|
+
export interface SeparatorSlots {
|
|
8
|
+
default?: (props: {}) => any
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type SeparatorVariants = VariantProps<typeof separator>
|
|
12
|
+
|
|
13
|
+
export interface SeparatorProps extends ComponentAttrs<typeof separator>, Pick<RekaSeparatorProps, 'as' | 'decorative'> {
|
|
14
|
+
orientation?: SeparatorVariants['orientation']
|
|
15
|
+
align?: 'start' | 'end' | 'center'
|
|
16
|
+
/** Display a label in the middle. */
|
|
17
|
+
label?: string
|
|
18
|
+
/**
|
|
19
|
+
* Display an icon in the middle.
|
|
20
|
+
*/
|
|
21
|
+
icon?: string
|
|
22
|
+
}
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { reactivePick } from '@vueuse/core'
|
|
27
|
+
import { Separator, useForwardProps } from 'reka-ui'
|
|
28
|
+
import { computed } from 'vue'
|
|
29
|
+
import { useTheme } from '../composables/useTheme'
|
|
30
|
+
|
|
31
|
+
const props = withDefaults(defineProps<SeparatorProps>(), {
|
|
32
|
+
orientation: 'horizontal',
|
|
33
|
+
position: 'center',
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const slots = defineSlots<SeparatorSlots>()
|
|
37
|
+
|
|
38
|
+
const rootProps = useForwardProps(reactivePick(props, 'as', 'decorative', 'orientation'))
|
|
39
|
+
|
|
40
|
+
const { theme, createStyler } = useTheme()
|
|
41
|
+
|
|
42
|
+
const style = computed(() => {
|
|
43
|
+
const styler = createStyler(theme.value.separator)
|
|
44
|
+
return styler(props)
|
|
45
|
+
})
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<Separator v-bind="rootProps" :class="style.root({ class: [props.class, props.ui?.root] })">
|
|
50
|
+
<div :class="style.line({ class: props.ui?.line, start: props.align === 'start' })"></div>
|
|
51
|
+
|
|
52
|
+
<template v-if="props.label || props.icon || slots.default">
|
|
53
|
+
<div :class="style.container({ class: props.ui?.container })">
|
|
54
|
+
<slot>
|
|
55
|
+
<span v-if="props.label" :class="style.label({ class: props.ui?.label })">{{ props.label }}</span>
|
|
56
|
+
<span v-else-if="props.icon" :class="style.icon({ class: [props.icon, props.ui?.icon] })"></span>
|
|
57
|
+
</slot>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div :class="style.line({ class: props.ui?.line, end: props.align === 'end' })"></div>
|
|
61
|
+
</template>
|
|
62
|
+
</Separator>
|
|
63
|
+
</template>
|
|
@@ -74,10 +74,10 @@ function onUpdate(value: any) {
|
|
|
74
74
|
@update:model-value="onUpdate"
|
|
75
75
|
>
|
|
76
76
|
<SwitchThumb :class="style.thumb({ class: props.ui?.thumb })">
|
|
77
|
-
<
|
|
77
|
+
<span v-if="props.loading" :class="style.icon({ class: [theme.app.icons.loading, props.ui?.icon], checked: true, unchecked: true })"></span>
|
|
78
78
|
<template v-else>
|
|
79
|
-
<
|
|
80
|
-
<
|
|
79
|
+
<span v-if="props.checkedIcon" :class="style.icon({ class: [props.checkedIcon, props.ui?.icon], checked: true })"></span>
|
|
80
|
+
<span v-if="props.uncheckedIcon" :class="style.icon({ class: [props.uncheckedIcon, props.ui?.icon], unchecked: true })"></span>
|
|
81
81
|
</template>
|
|
82
82
|
</SwitchThumb>
|
|
83
83
|
</SwitchRoot>
|