@byyuurin/ui 0.0.6 → 0.0.8
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} +8 -8
- package/dist/module.mjs.map +1 -0
- package/dist/runtime/app/injections.d.ts +16 -0
- package/dist/runtime/app/injections.js +31 -0
- package/dist/runtime/components/Accordion.vue +27 -38
- package/dist/runtime/components/Alert.vue +23 -16
- package/dist/runtime/components/App.vue +15 -15
- package/dist/runtime/components/Avatar.vue +73 -0
- package/dist/runtime/components/AvatarGroup.vue +90 -0
- package/dist/runtime/components/Badge.vue +15 -10
- package/dist/runtime/components/Breadcrumb.vue +105 -0
- package/dist/runtime/components/Button.vue +22 -23
- package/dist/runtime/components/ButtonGroup.vue +12 -10
- package/dist/runtime/components/Card.vue +16 -8
- package/dist/runtime/components/Carousel.vue +19 -12
- package/dist/runtime/components/Checkbox.vue +16 -12
- package/dist/runtime/components/Chip.vue +17 -12
- package/dist/runtime/components/Collapsible.vue +56 -0
- package/dist/runtime/components/Drawer.vue +18 -17
- package/dist/runtime/components/Input.vue +28 -28
- package/dist/runtime/components/InputNumber.vue +169 -0
- package/dist/runtime/components/Kbd.vue +51 -0
- package/dist/runtime/components/Link.vue +301 -72
- package/dist/runtime/components/LinkBase.vue +88 -0
- package/dist/runtime/components/Modal.vue +11 -9
- package/dist/runtime/components/ModalProvider.vue +2 -1
- package/dist/runtime/components/Pagination.vue +30 -30
- package/dist/runtime/components/PinInput.vue +7 -7
- package/dist/runtime/components/Popover.vue +7 -7
- package/dist/runtime/components/Progress.vue +165 -0
- package/dist/runtime/components/RadioGroup.vue +33 -29
- package/dist/runtime/components/Select.vue +40 -40
- package/dist/runtime/components/Separator.vue +63 -0
- package/dist/runtime/components/Skeleton.vue +33 -0
- package/dist/runtime/components/Slider.vue +6 -6
- package/dist/runtime/components/Switch.vue +14 -15
- package/dist/runtime/components/Table.vue +300 -0
- package/dist/runtime/components/Tabs.vue +25 -21
- package/dist/runtime/components/Textarea.vue +11 -11
- package/dist/runtime/components/Toast.vue +15 -14
- package/dist/runtime/components/Toaster.vue +5 -39
- package/dist/runtime/components/Tooltip.vue +7 -7
- package/dist/runtime/composables/useAvatarGroup.d.ts +4 -0
- package/dist/runtime/composables/useAvatarGroup.js +8 -0
- package/dist/runtime/composables/useButtonGroup.d.ts +4 -12
- package/dist/runtime/composables/{useButtonGroup.mjs → useButtonGroup.js} +1 -6
- package/dist/runtime/composables/useComponentIcons.d.ts +9 -9
- package/dist/runtime/composables/useComponentIcons.js +24 -0
- package/dist/runtime/composables/useKbd.d.ts +35 -0
- package/dist/runtime/composables/useKbd.js +49 -0
- package/dist/runtime/composables/useLocale.d.ts +8 -0
- package/dist/runtime/composables/useLocale.js +22 -0
- package/dist/runtime/composables/useModal.d.ts +2 -7
- package/dist/runtime/composables/{useModal.mjs → useModal.js} +1 -6
- package/dist/runtime/composables/useTheme.d.ts +2 -6
- package/dist/runtime/composables/useTheme.js +16 -0
- package/dist/runtime/composables/useToast.d.ts +1 -1
- package/dist/runtime/index.d.ts +40 -0
- package/dist/runtime/index.js +40 -0
- package/dist/runtime/locale/en.d.ts +2 -0
- package/dist/runtime/locale/en.js +28 -0
- package/dist/runtime/locale/index.d.ts +2 -0
- package/dist/runtime/locale/index.js +2 -0
- package/dist/runtime/locale/zh-tw.d.ts +2 -0
- package/dist/runtime/locale/zh-tw.js +28 -0
- package/dist/runtime/theme/accordion.d.ts +5 -5
- 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 +8 -5
- package/dist/runtime/theme/app.js +18 -0
- package/dist/runtime/theme/avatar-group.d.ts +52 -0
- package/dist/runtime/theme/avatar-group.js +32 -0
- package/dist/runtime/theme/avatar.d.ts +56 -0
- package/dist/runtime/theme/avatar.js +34 -0
- package/dist/runtime/theme/badge.d.ts +45 -21
- package/dist/runtime/theme/{badge.mjs → badge.js} +2 -2
- package/dist/runtime/theme/breadcrumb.d.ts +67 -0
- package/dist/runtime/theme/breadcrumb.js +44 -0
- package/dist/runtime/theme/button-group.d.ts +2 -2
- package/dist/runtime/theme/button.d.ts +61 -115
- 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 +47 -14
- package/dist/runtime/theme/{chip.mjs → chip.js} +7 -9
- 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 +37 -27
- package/dist/runtime/theme/index.js +37 -0
- package/dist/runtime/theme/input-number.d.ts +141 -0
- package/dist/runtime/theme/input-number.js +95 -0
- package/dist/runtime/theme/input.d.ts +77 -105
- package/dist/runtime/theme/{input.mjs → input.js} +25 -25
- package/dist/runtime/theme/kbd.d.ts +39 -0
- package/dist/runtime/theme/kbd.js +26 -0
- 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/progress.d.ts +122 -0
- package/dist/runtime/theme/progress.js +95 -0
- 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 +93 -108
- package/dist/runtime/theme/{select.mjs → select.js} +31 -31
- package/dist/runtime/theme/separator.d.ts +95 -0
- package/dist/runtime/theme/separator.js +53 -0
- package/dist/runtime/theme/skeleton.d.ts +8 -0
- package/dist/runtime/theme/skeleton.js +7 -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} +3 -3
- package/dist/runtime/theme/table.d.ts +89 -0
- package/dist/runtime/theme/table.js +35 -0
- package/dist/runtime/theme/tabs.d.ts +70 -53
- package/dist/runtime/theme/{tabs.mjs → tabs.js} +12 -12
- 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} +3 -3
- 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 +37 -27
- package/dist/runtime/types/index.d.ts +5 -4
- package/dist/runtime/types/index.js +3 -0
- package/dist/runtime/types/locale.d.ts +23 -0
- package/dist/runtime/types/locale.js +0 -0
- package/dist/runtime/types/utils.d.ts +1 -1
- package/dist/runtime/types/utils.js +0 -0
- package/dist/runtime/utils/index.d.ts +9 -4
- package/dist/runtime/utils/{index.mjs → index.js} +9 -7
- 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/utils/translator.d.ts +18 -0
- package/dist/runtime/utils/translator.js +8 -0
- package/dist/runtime/vue/stubs.d.ts +9 -0
- package/dist/runtime/vue/stubs.js +16 -0
- package/dist/shared/ui.ba24b380.mjs +4 -0
- package/dist/shared/ui.ba24b380.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 +35 -8
- 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 +50 -38
- package/dist/index.d.ts +0 -29
- package/dist/index.mjs +0 -29
- package/dist/nuxt.mjs.map +0 -1
- package/dist/runtime/composables/useComponentIcons.mjs +0 -24
- package/dist/runtime/composables/useTheme.mjs +0 -26
- package/dist/runtime/theme/app.mjs +0 -15
- 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 +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/{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
- /package/dist/runtime/{composables/defineInjection.d.ts → utils/vue.d.ts} +0 -0
- /package/dist/runtime/{composables/defineInjection.mjs → utils/vue.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
|
-
export interface
|
|
8
|
+
export interface LinkSlots {
|
|
9
|
+
default?: (props: { active: boolean }) => any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface NuxtLinkProps extends Omit<RouterLinkProps, 'to'> {
|
|
13
|
+
/**
|
|
14
|
+
* Route Location the link should navigate to when clicked on.
|
|
15
|
+
*/
|
|
16
|
+
to?: RouteLocationRaw // need to manually type to avoid breaking typedPages
|
|
17
|
+
/**
|
|
18
|
+
* An alias for `to`. If used with `to`, `href` will be ignored
|
|
19
|
+
*/
|
|
20
|
+
href?: NuxtLinkProps['to']
|
|
21
|
+
/**
|
|
22
|
+
* Forces the link to be considered as external (true) or internal (false). This is helpful to handle edge-cases
|
|
23
|
+
*/
|
|
24
|
+
external?: boolean
|
|
25
|
+
/**
|
|
26
|
+
* Where to display the linked URL, as the name for a browsing context.
|
|
27
|
+
*/
|
|
28
|
+
target?: '_blank' | '_parent' | '_self' | '_top' | (string & {}) | null
|
|
29
|
+
/**
|
|
30
|
+
* A rel attribute value to apply on the link. Defaults to "noopener noreferrer" for external links.
|
|
31
|
+
*/
|
|
32
|
+
rel?: 'noopener' | 'noreferrer' | 'nofollow' | 'sponsored' | 'ugc' | (string & {}) | null
|
|
33
|
+
/**
|
|
34
|
+
* If set to true, no rel attribute will be added to the link
|
|
35
|
+
*/
|
|
36
|
+
noRel?: boolean
|
|
37
|
+
/**
|
|
38
|
+
* A class to apply to links that have been prefetched.
|
|
39
|
+
*/
|
|
40
|
+
prefetchedClass?: string
|
|
41
|
+
/**
|
|
42
|
+
* When enabled will prefetch middleware, layouts and payloads of links in the viewport.
|
|
43
|
+
*/
|
|
44
|
+
prefetch?: boolean
|
|
45
|
+
/**
|
|
46
|
+
* Allows controlling when to prefetch links. By default, prefetch is triggered only on visibility.
|
|
47
|
+
*/
|
|
48
|
+
prefetchOn?: 'visibility' | 'interaction' | Partial<{
|
|
49
|
+
visibility: boolean
|
|
50
|
+
interaction: boolean
|
|
51
|
+
}>
|
|
52
|
+
/**
|
|
53
|
+
* Escape hatch to disable `prefetch` attribute.
|
|
54
|
+
*/
|
|
55
|
+
noPrefetch?: boolean
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface LinkProps extends Omit<ComponentAttrs<typeof link>, 'ui'>, NuxtLinkProps {
|
|
59
|
+
/**
|
|
60
|
+
* The element or component this component should render as when not a link.
|
|
61
|
+
* @default "button"
|
|
62
|
+
*/
|
|
7
63
|
as?: PrimitiveProps['as']
|
|
8
|
-
|
|
9
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The type of the button when not a link.
|
|
66
|
+
* @default "button"
|
|
67
|
+
*/
|
|
68
|
+
type?: ButtonHTMLAttributes['type']
|
|
10
69
|
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
70
|
disabled?: boolean
|
|
71
|
+
/** Force the link to be active independent of the current route. */
|
|
72
|
+
active?: boolean
|
|
73
|
+
/** Will only be active if the current route is an exact match. */
|
|
74
|
+
exact?: boolean
|
|
75
|
+
/** Will only be active if the current route query is an exact match. */
|
|
76
|
+
exactQuery?: boolean | 'partial'
|
|
77
|
+
/** Will only be active if the current route hash is an exact match. */
|
|
78
|
+
exactHash?: boolean
|
|
79
|
+
/** The class to apply when the link is inactive. */
|
|
80
|
+
inactiveClass?: string
|
|
81
|
+
/** The class to apply when the link is disabled. */
|
|
82
|
+
disableClass?: string
|
|
83
|
+
custom?: boolean
|
|
84
|
+
underline?: boolean
|
|
22
85
|
/** When `true`, only styles from `class`, `ui.active`, and `ui.inactive` will be applied. */
|
|
23
86
|
raw?: boolean
|
|
24
|
-
ui?: {
|
|
25
|
-
active?: string
|
|
26
|
-
inactive?: string
|
|
27
|
-
disabled?: string
|
|
28
|
-
}
|
|
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 || href,
|
|
321
|
+
target: isExternalLink ? '_blank' : target || 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 || href) as string),
|
|
336
|
+
target: isExternalLink ? '_blank' : target || 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>
|
|
@@ -8,13 +8,13 @@ export interface ModalEmits extends DialogRootEmits {}
|
|
|
8
8
|
|
|
9
9
|
export interface ModalSlots {
|
|
10
10
|
default?: (props: { open: boolean }) => any
|
|
11
|
-
content?: (props?:
|
|
12
|
-
header?: (props?:
|
|
13
|
-
title?: (props?:
|
|
14
|
-
description?: (props?:
|
|
15
|
-
close?: (props?:
|
|
16
|
-
body?: (props?:
|
|
17
|
-
footer?: (props?:
|
|
11
|
+
content?: (props?: {}) => any
|
|
12
|
+
header?: (props?: {}) => any
|
|
13
|
+
title?: (props?: {}) => any
|
|
14
|
+
description?: (props?: {}) => any
|
|
15
|
+
close?: (props?: {}) => any
|
|
16
|
+
body?: (props?: {}) => any
|
|
17
|
+
footer?: (props?: {}) => any
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
type ModalVariants = VariantProps<typeof modal>
|
|
@@ -28,7 +28,6 @@ export interface ModalProps extends ComponentAttrs<typeof modal>, DialogRootProp
|
|
|
28
28
|
portal?: boolean
|
|
29
29
|
/** @default true */
|
|
30
30
|
overlay?: boolean
|
|
31
|
-
blur?: boolean
|
|
32
31
|
/** @default true */
|
|
33
32
|
transition?: boolean
|
|
34
33
|
/**
|
|
@@ -37,7 +36,7 @@ export interface ModalProps extends ComponentAttrs<typeof modal>, DialogRootProp
|
|
|
37
36
|
*/
|
|
38
37
|
dismissible?: boolean
|
|
39
38
|
close?: ButtonProps | boolean
|
|
40
|
-
/** @default
|
|
39
|
+
/** @default app.icons.close */
|
|
41
40
|
closeIcon?: string
|
|
42
41
|
}
|
|
43
42
|
</script>
|
|
@@ -46,6 +45,7 @@ export interface ModalProps extends ComponentAttrs<typeof modal>, DialogRootProp
|
|
|
46
45
|
import { reactivePick } from '@vueuse/core'
|
|
47
46
|
import { DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle, DialogTrigger, useForwardPropsEmits } from 'reka-ui'
|
|
48
47
|
import { computed, toRef } from 'vue'
|
|
48
|
+
import { useLocale } from '../composables/useLocale'
|
|
49
49
|
import { useTheme } from '../composables/useTheme'
|
|
50
50
|
import Button from './Button.vue'
|
|
51
51
|
|
|
@@ -72,6 +72,7 @@ const contentEvents = computed(() => {
|
|
|
72
72
|
}
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
+
const { t } = useLocale()
|
|
75
76
|
const { theme, createStyler } = useTheme()
|
|
76
77
|
const style = computed(() => {
|
|
77
78
|
const styler = createStyler(theme.value.modal)
|
|
@@ -115,6 +116,7 @@ const style = computed(() => {
|
|
|
115
116
|
:icon="props.closeIcon || theme.app.icons.close"
|
|
116
117
|
v-bind="typeof props.close === 'boolean' ? {} : props.close"
|
|
117
118
|
:class="style.close({ class: props.ui?.close })"
|
|
119
|
+
:aria-label="t('modal.close')"
|
|
118
120
|
/>
|
|
119
121
|
</slot>
|
|
120
122
|
</DialogClose>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { injectModalState
|
|
2
|
+
import { injectModalState } from '../app/injections'
|
|
3
|
+
import { useModal } from '../composables/useModal'
|
|
3
4
|
|
|
4
5
|
const modalState = injectModalState()
|
|
5
6
|
const { isOpen } = useModal()
|
|
@@ -3,6 +3,27 @@ import type { PaginationRootEmits, PaginationRootProps } from 'reka-ui'
|
|
|
3
3
|
import type { pagination } from '../theme'
|
|
4
4
|
import type { ButtonProps, ComponentAttrs } from '../types'
|
|
5
5
|
|
|
6
|
+
export interface PaginationEmits extends PaginationRootEmits {}
|
|
7
|
+
|
|
8
|
+
export interface PaginationSlots {
|
|
9
|
+
first?: (props?: {}) => any
|
|
10
|
+
prev?: (props?: {}) => any
|
|
11
|
+
next?: (props?: {}) => any
|
|
12
|
+
last?: (props?: {}) => any
|
|
13
|
+
ellipsis?: (props?: {}) => any
|
|
14
|
+
item?: (props: {
|
|
15
|
+
page: number
|
|
16
|
+
pageCount: number
|
|
17
|
+
item: {
|
|
18
|
+
type: 'ellipsis'
|
|
19
|
+
} | {
|
|
20
|
+
type: 'page'
|
|
21
|
+
value: number
|
|
22
|
+
}
|
|
23
|
+
index: number
|
|
24
|
+
}) => any
|
|
25
|
+
}
|
|
26
|
+
|
|
6
27
|
export interface PaginationProps extends ComponentAttrs<typeof pagination>, Pick<PaginationRootProps, 'as' | 'defaultPage' | 'disabled' | 'itemsPerPage' | 'page' | 'showEdges' | 'siblingCount' | 'total'> {
|
|
7
28
|
/**
|
|
8
29
|
* The icon to use for the first page control.
|
|
@@ -16,12 +37,12 @@ export interface PaginationProps extends ComponentAttrs<typeof pagination>, Pick
|
|
|
16
37
|
lastIcon?: string
|
|
17
38
|
/**
|
|
18
39
|
* The icon to use for the previous page control.
|
|
19
|
-
* @default app.icons.
|
|
40
|
+
* @default app.icons.chevronLeft
|
|
20
41
|
*/
|
|
21
42
|
prevIcon?: string
|
|
22
43
|
/**
|
|
23
44
|
* The icon to use for the next page control.
|
|
24
|
-
* @default app.icons.
|
|
45
|
+
* @default app.icons.chevronRight
|
|
25
46
|
*/
|
|
26
47
|
nextIcon?: string
|
|
27
48
|
/**
|
|
@@ -31,17 +52,17 @@ export interface PaginationProps extends ComponentAttrs<typeof pagination>, Pick
|
|
|
31
52
|
ellipsisIcon?: string
|
|
32
53
|
/**
|
|
33
54
|
* The size of the pagination controls.
|
|
34
|
-
* @default
|
|
55
|
+
* @default "md"
|
|
35
56
|
*/
|
|
36
57
|
size?: ButtonProps['size']
|
|
37
58
|
/**
|
|
38
59
|
* The variant of the pagination controls.
|
|
39
|
-
* @default
|
|
60
|
+
* @default "outline"
|
|
40
61
|
*/
|
|
41
62
|
variant?: ButtonProps['variant']
|
|
42
63
|
/**
|
|
43
64
|
* The variant of the active pagination control.
|
|
44
|
-
* @default
|
|
65
|
+
* @default "solid"
|
|
45
66
|
*/
|
|
46
67
|
activeVariant?: ButtonProps['variant']
|
|
47
68
|
/**
|
|
@@ -50,27 +71,6 @@ export interface PaginationProps extends ComponentAttrs<typeof pagination>, Pick
|
|
|
50
71
|
*/
|
|
51
72
|
showControls?: boolean
|
|
52
73
|
}
|
|
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
74
|
</script>
|
|
75
75
|
|
|
76
76
|
<script setup lang="ts">
|
|
@@ -97,10 +97,10 @@ const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultPage',
|
|
|
97
97
|
|
|
98
98
|
const { theme, createStyler } = useTheme()
|
|
99
99
|
|
|
100
|
-
const firstIcon = computed(() => props.firstIcon || theme.value.app.icons.
|
|
101
|
-
const prevIcon = computed(() => props.prevIcon || theme.value.app.icons.
|
|
102
|
-
const nextIcon = computed(() => props.nextIcon || theme.value.app.icons.
|
|
103
|
-
const lastIcon = computed(() => props.lastIcon || theme.value.app.icons.
|
|
100
|
+
const firstIcon = computed(() => props.firstIcon || theme.value.app.icons.chevronDoubleLeft)
|
|
101
|
+
const prevIcon = computed(() => props.prevIcon || theme.value.app.icons.chevronLeft)
|
|
102
|
+
const nextIcon = computed(() => props.nextIcon || theme.value.app.icons.chevronRight)
|
|
103
|
+
const lastIcon = computed(() => props.lastIcon || theme.value.app.icons.chevronDoubleRight)
|
|
104
104
|
const ellipsisIcon = computed(() => props.ellipsisIcon || theme.value.app.icons.ellipsis)
|
|
105
105
|
|
|
106
106
|
const style = computed(() => {
|