@nuxt/ui 3.0.2 → 3.1.0
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/.nuxt/ui/accordion.ts +25 -4
- package/.nuxt/ui/alert.ts +52 -31
- package/.nuxt/ui/avatar-group.ts +24 -3
- package/.nuxt/ui/avatar.ts +26 -5
- package/.nuxt/ui/badge.ts +56 -35
- package/.nuxt/ui/breadcrumb.ts +28 -7
- package/.nuxt/ui/button-group.ts +23 -2
- package/.nuxt/ui/button.ts +66 -45
- package/.nuxt/ui/calendar.ts +39 -18
- package/.nuxt/ui/card.ts +28 -7
- package/.nuxt/ui/carousel.ts +29 -8
- package/.nuxt/ui/checkbox-group.ts +82 -0
- package/.nuxt/ui/checkbox.ts +163 -29
- package/.nuxt/ui/chip.ts +31 -10
- package/.nuxt/ui/collapsible.ts +23 -2
- package/.nuxt/ui/color-picker.ts +26 -5
- package/.nuxt/ui/command-palette.ts +37 -16
- package/.nuxt/ui/container.ts +23 -2
- package/.nuxt/ui/context-menu.ts +56 -35
- package/.nuxt/ui/drawer.ts +33 -12
- package/.nuxt/ui/dropdown-menu.ts +57 -36
- package/.nuxt/ui/form-field.ts +29 -8
- package/.nuxt/ui/form.ts +23 -2
- package/.nuxt/ui/index.ts +1 -0
- package/.nuxt/ui/input-menu.ts +65 -44
- package/.nuxt/ui/input-number.ts +43 -22
- package/.nuxt/ui/input.ts +46 -25
- package/.nuxt/ui/kbd.ts +27 -6
- package/.nuxt/ui/link.ts +26 -5
- package/.nuxt/ui/modal.ts +28 -7
- package/.nuxt/ui/navigation-menu.ts +102 -83
- package/.nuxt/ui/pagination.ts +23 -2
- package/.nuxt/ui/pin-input.ts +43 -22
- package/.nuxt/ui/popover.ts +25 -4
- package/.nuxt/ui/progress.ts +40 -19
- package/.nuxt/ui/radio-group.ts +273 -37
- package/.nuxt/ui/select-menu.ts +59 -35
- package/.nuxt/ui/select.ts +55 -34
- package/.nuxt/ui/separator.ts +31 -10
- package/.nuxt/ui/skeleton.ts +24 -3
- package/.nuxt/ui/slideover.ts +27 -6
- package/.nuxt/ui/slider.ts +39 -18
- package/.nuxt/ui/stepper.ts +41 -20
- package/.nuxt/ui/switch.ts +43 -22
- package/.nuxt/ui/table.ts +38 -17
- package/.nuxt/ui/tabs.ts +55 -34
- package/.nuxt/ui/textarea.ts +63 -37
- package/.nuxt/ui/toast.ts +47 -26
- package/.nuxt/ui/toaster.ts +23 -2
- package/.nuxt/ui/tooltip.ts +25 -4
- package/.nuxt/ui/tree.ts +41 -20
- package/.nuxt/ui.css +56 -12
- package/README.md +11 -0
- package/cli/templates.mjs +18 -17
- package/dist/module.json +5 -5
- package/dist/module.mjs +11 -7
- package/dist/runtime/components/Accordion.vue +36 -93
- package/dist/runtime/components/Accordion.vue.d.ts +91 -0
- package/dist/runtime/components/Alert.vue +37 -100
- package/dist/runtime/components/Alert.vue.d.ts +96 -0
- package/dist/runtime/components/App.vue +28 -34
- package/dist/runtime/components/App.vue.d.ts +24 -0
- package/dist/runtime/components/Avatar.vue +42 -75
- package/dist/runtime/components/Avatar.vue.d.ts +60 -0
- package/dist/runtime/components/AvatarGroup.vue +40 -77
- package/dist/runtime/components/AvatarGroup.vue.d.ts +40 -0
- package/dist/runtime/components/Badge.vue +33 -62
- package/dist/runtime/components/Badge.vue.d.ts +62 -0
- package/dist/runtime/components/Breadcrumb.vue +37 -90
- package/dist/runtime/components/Breadcrumb.vue.d.ts +82 -0
- package/dist/runtime/components/Button.vue +95 -104
- package/dist/runtime/components/Button.vue.d.ts +73 -0
- package/dist/runtime/components/ButtonGroup.vue +20 -46
- package/dist/runtime/components/ButtonGroup.vue.d.ts +55 -0
- package/dist/runtime/components/Calendar.vue +67 -150
- package/dist/runtime/components/Calendar.vue.d.ts +107 -0
- package/dist/runtime/components/Card.vue +18 -40
- package/dist/runtime/components/Card.vue.d.ts +38 -0
- package/dist/runtime/components/Carousel.vue +112 -234
- package/dist/runtime/components/Carousel.vue.d.ts +120 -0
- package/dist/runtime/components/Checkbox.vue +52 -93
- package/dist/runtime/components/Checkbox.vue.d.ts +76 -0
- package/dist/runtime/components/CheckboxGroup.vue +121 -0
- package/dist/runtime/components/CheckboxGroup.vue.d.ts +75 -0
- package/dist/runtime/components/Chip.vue +26 -69
- package/dist/runtime/components/Chip.vue.d.ts +71 -0
- package/dist/runtime/components/Collapsible.vue +22 -41
- package/dist/runtime/components/Collapsible.vue.d.ts +50 -0
- package/dist/runtime/components/ColorPicker.vue +111 -197
- package/dist/runtime/components/ColorPicker.vue.d.ts +63 -0
- package/dist/runtime/components/CommandPalette.vue +96 -237
- package/dist/runtime/components/CommandPalette.vue.d.ts +173 -0
- package/dist/runtime/components/Container.vue +15 -28
- package/dist/runtime/components/Container.vue.d.ts +27 -0
- package/dist/runtime/components/ContextMenu.vue +34 -133
- package/dist/runtime/components/ContextMenu.vue.d.ts +127 -0
- package/dist/runtime/components/ContextMenuContent.vue +73 -81
- package/dist/runtime/components/ContextMenuContent.vue.d.ts +105 -0
- package/dist/runtime/components/Drawer.vue +49 -83
- package/dist/runtime/components/Drawer.vue.d.ts +88 -0
- package/dist/runtime/components/DropdownMenu.vue +39 -142
- package/dist/runtime/components/DropdownMenu.vue.d.ts +141 -0
- package/dist/runtime/components/DropdownMenuContent.vue +78 -88
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +55 -0
- package/dist/runtime/components/Form.vue +135 -220
- package/dist/runtime/components/Form.vue.d.ts +66 -0
- package/dist/runtime/components/FormField.vue +35 -77
- package/dist/runtime/components/FormField.vue.d.ts +70 -0
- package/dist/runtime/components/Icon.vue +12 -19
- package/dist/runtime/components/Icon.vue.d.ts +17 -0
- package/dist/runtime/components/Input.vue +82 -140
- package/dist/runtime/components/Input.vue.d.ts +91 -0
- package/dist/runtime/components/InputMenu.vue +185 -332
- package/dist/runtime/components/InputMenu.vue.d.ts +312 -0
- package/dist/runtime/components/InputNumber.vue +71 -133
- package/dist/runtime/components/InputNumber.vue.d.ts +193 -0
- package/dist/runtime/components/Kbd.vue +20 -46
- package/dist/runtime/components/Kbd.vue.d.ts +55 -0
- package/dist/runtime/components/Link.vue +98 -176
- package/dist/runtime/components/Link.vue.d.ts +124 -0
- package/dist/runtime/components/LinkBase.vue +33 -42
- package/dist/runtime/components/LinkBase.vue.d.ts +48 -0
- package/dist/runtime/components/Modal.vue +53 -116
- package/dist/runtime/components/Modal.vue.d.ts +109 -0
- package/dist/runtime/components/NavigationMenu.vue +77 -209
- package/dist/runtime/components/NavigationMenu.vue.d.ts +159 -0
- package/dist/runtime/components/OverlayProvider.vue +14 -18
- package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
- package/dist/runtime/components/Pagination.vue +46 -140
- package/dist/runtime/components/Pagination.vue.d.ts +143 -0
- package/dist/runtime/components/PinInput.vue +61 -78
- package/dist/runtime/components/PinInput.vue.d.ts +68 -0
- package/dist/runtime/components/Popover.vue +47 -84
- package/dist/runtime/components/Popover.vue.d.ts +80 -0
- package/dist/runtime/components/Progress.vue +70 -131
- package/dist/runtime/components/Progress.vue.d.ts +97 -0
- package/dist/runtime/components/RadioGroup.vue +70 -132
- package/dist/runtime/components/RadioGroup.vue.d.ts +88 -0
- package/dist/runtime/components/Select.vue +110 -224
- package/dist/runtime/components/Select.vue.d.ts +139 -0
- package/dist/runtime/components/SelectMenu.vue +161 -310
- package/dist/runtime/components/SelectMenu.vue.d.ts +184 -0
- package/dist/runtime/components/Separator.vue +29 -71
- package/dist/runtime/components/Separator.vue.d.ts +75 -0
- package/dist/runtime/components/Skeleton.vue +21 -23
- package/dist/runtime/components/Skeleton.vue.d.ts +26 -0
- package/dist/runtime/components/Slideover.vue +53 -120
- package/dist/runtime/components/Slideover.vue.d.ts +111 -0
- package/dist/runtime/components/Slider.vue +46 -84
- package/dist/runtime/components/Slider.vue.d.ts +71 -0
- package/dist/runtime/components/Stepper.vue +45 -115
- package/dist/runtime/components/Stepper.vue.d.ts +89 -0
- package/dist/runtime/components/Switch.vue +45 -93
- package/dist/runtime/components/Switch.vue.d.ts +73 -0
- package/dist/runtime/components/Table.vue +163 -267
- package/dist/runtime/components/Table.vue.d.ts +183 -0
- package/dist/runtime/components/Tabs.vue +41 -107
- package/dist/runtime/components/Tabs.vue.d.ts +104 -0
- package/dist/runtime/components/Textarea.vue +113 -158
- package/dist/runtime/components/Textarea.vue.d.ts +95 -0
- package/dist/runtime/components/Toast.vue +49 -110
- package/dist/runtime/components/Toast.vue.d.ts +95 -0
- package/dist/runtime/components/Toaster.vue +70 -107
- package/dist/runtime/components/Toaster.vue.d.ts +63 -0
- package/dist/runtime/components/Tooltip.vue +38 -65
- package/dist/runtime/components/Tooltip.vue.d.ts +65 -0
- package/dist/runtime/components/Tree.vue +59 -166
- package/dist/runtime/components/Tree.vue.d.ts +128 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
- package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
- package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
- package/dist/runtime/composables/useFormField.d.ts +2 -2
- package/dist/runtime/composables/useOverlay.d.ts +14 -7
- package/dist/runtime/composables/useOverlay.js +14 -6
- package/dist/runtime/composables/usePortal.d.ts +6 -0
- package/dist/runtime/composables/usePortal.js +17 -0
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/inertia/components/Link.vue +146 -0
- package/dist/runtime/inertia/components/Link.vue.d.ts +92 -0
- package/dist/runtime/inertia/stubs.d.ts +43 -0
- package/dist/runtime/inertia/stubs.js +82 -0
- package/dist/runtime/locale/bg.d.ts +3 -0
- package/dist/runtime/locale/bg.js +54 -0
- package/dist/runtime/locale/index.d.ts +5 -1
- package/dist/runtime/locale/index.js +5 -1
- package/dist/runtime/locale/kk.d.ts +3 -0
- package/dist/runtime/locale/kk.js +54 -0
- package/dist/runtime/locale/tj.d.ts +3 -0
- package/dist/runtime/locale/tj.js +54 -0
- package/dist/runtime/locale/ug_cn.d.ts +3 -0
- package/dist/runtime/locale/ug_cn.js +55 -0
- package/dist/runtime/types/form.d.ts +4 -1
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/utils.d.ts +47 -7
- package/dist/runtime/utils/link.d.ts +3 -3
- package/dist/runtime/utils/link.js +1 -0
- package/dist/runtime/utils/tv.js +2 -2
- package/dist/runtime/vue/components/Icon.vue +7 -8
- package/dist/runtime/vue/components/Icon.vue.d.ts +14 -0
- package/dist/runtime/vue/components/Link.vue +118 -202
- package/dist/runtime/vue/components/Link.vue.d.ts +124 -0
- package/dist/runtime/vue/stubs.d.ts +2 -2
- package/dist/shared/{ui.BkNUP964.mjs → ui.D7lOOabO.mjs} +621 -362
- package/dist/types.d.mts +3 -5
- package/dist/unplugin.d.mts +4 -0
- package/dist/unplugin.mjs +25 -4
- package/dist/vite.mjs +1 -1
- package/package.json +94 -53
- package/dist/module.cjs +0 -62
- package/dist/module.d.cts +0 -45
- package/dist/module.d.ts +0 -45
- package/dist/shared/ui.BL-XB3u1.cjs +0 -3555
- package/dist/types.d.ts +0 -7
- package/dist/unplugin.cjs +0 -232
- package/dist/unplugin.d.cts +0 -62
- package/dist/unplugin.d.ts +0 -62
- package/dist/vite.cjs +0 -23
- package/dist/vite.d.cts +0 -15
- package/dist/vite.d.ts +0 -15
|
@@ -1,122 +1,113 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import type { AppConfig } from '@nuxt/schema'
|
|
4
|
-
import _appConfig from '#build/app.config'
|
|
5
|
-
import theme from '#build/ui/button'
|
|
6
|
-
import type { LinkProps } from './Link.vue'
|
|
7
|
-
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
|
|
8
|
-
import { tv } from '../utils/tv'
|
|
9
|
-
import type { AvatarProps } from '../types'
|
|
10
|
-
import type { PartialString } from '../types/utils'
|
|
11
|
-
|
|
12
|
-
const appConfigButton = _appConfig as AppConfig & { ui: { button: Partial<typeof theme> } }
|
|
13
|
-
|
|
14
|
-
const button = tv({ extend: tv(theme), ...(appConfigButton.ui?.button || {}) })
|
|
15
|
-
|
|
16
|
-
type ButtonVariants = VariantProps<typeof button>
|
|
17
|
-
|
|
18
|
-
export interface ButtonProps extends UseComponentIconsProps, Omit<LinkProps, 'raw' | 'custom'> {
|
|
19
|
-
label?: string
|
|
20
|
-
/**
|
|
21
|
-
* @defaultValue 'primary'
|
|
22
|
-
*/
|
|
23
|
-
color?: ButtonVariants['color']
|
|
24
|
-
activeColor?: ButtonVariants['color']
|
|
25
|
-
/**
|
|
26
|
-
* @defaultValue 'solid'
|
|
27
|
-
*/
|
|
28
|
-
variant?: ButtonVariants['variant']
|
|
29
|
-
activeVariant?: ButtonVariants['variant']
|
|
30
|
-
/**
|
|
31
|
-
* @defaultValue 'md'
|
|
32
|
-
*/
|
|
33
|
-
size?: ButtonVariants['size']
|
|
34
|
-
/** Render the button with equal padding on all sides. */
|
|
35
|
-
square?: boolean
|
|
36
|
-
/** Render the button full width. */
|
|
37
|
-
block?: boolean
|
|
38
|
-
/** Set loading state automatically based on the `@click` promise state */
|
|
39
|
-
loadingAuto?: boolean
|
|
40
|
-
onClick?: ((event: MouseEvent) => void | Promise<void>) | Array<((event: MouseEvent) => void | Promise<void>)>
|
|
41
|
-
class?: any
|
|
42
|
-
ui?: PartialString<typeof button.slots>
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface ButtonSlots {
|
|
46
|
-
leading(props?: {}): any
|
|
47
|
-
default(props?: {}): any
|
|
48
|
-
trailing(props?: {}): any
|
|
49
|
-
}
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui/button";
|
|
50
3
|
</script>
|
|
51
4
|
|
|
52
|
-
<script setup
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import
|
|
61
|
-
import
|
|
62
|
-
import
|
|
63
|
-
import
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { computed, ref, inject } from "vue";
|
|
7
|
+
import { defu } from "defu";
|
|
8
|
+
import { useForwardProps } from "reka-ui";
|
|
9
|
+
import { useAppConfig } from "#imports";
|
|
10
|
+
import { useComponentIcons } from "../composables/useComponentIcons";
|
|
11
|
+
import { useButtonGroup } from "../composables/useButtonGroup";
|
|
12
|
+
import { formLoadingInjectionKey } from "../composables/useFormField";
|
|
13
|
+
import { omit } from "../utils";
|
|
14
|
+
import { tv } from "../utils/tv";
|
|
15
|
+
import { pickLinkProps } from "../utils/link";
|
|
16
|
+
import UIcon from "./Icon.vue";
|
|
17
|
+
import UAvatar from "./Avatar.vue";
|
|
18
|
+
import ULink from "./Link.vue";
|
|
19
|
+
import ULinkBase from "./LinkBase.vue";
|
|
20
|
+
const props = defineProps({
|
|
21
|
+
label: { type: String, required: false },
|
|
22
|
+
color: { type: null, required: false },
|
|
23
|
+
activeColor: { type: null, required: false },
|
|
24
|
+
variant: { type: null, required: false },
|
|
25
|
+
activeVariant: { type: null, required: false },
|
|
26
|
+
size: { type: null, required: false },
|
|
27
|
+
square: { type: Boolean, required: false },
|
|
28
|
+
block: { type: Boolean, required: false },
|
|
29
|
+
loadingAuto: { type: Boolean, required: false },
|
|
30
|
+
onClick: { type: [Function, Array], required: false },
|
|
31
|
+
class: { type: null, required: false },
|
|
32
|
+
ui: { type: null, required: false },
|
|
33
|
+
icon: { type: String, required: false },
|
|
34
|
+
avatar: { type: Object, required: false },
|
|
35
|
+
leading: { type: Boolean, required: false },
|
|
36
|
+
leadingIcon: { type: String, required: false },
|
|
37
|
+
trailing: { type: Boolean, required: false },
|
|
38
|
+
trailingIcon: { type: String, required: false },
|
|
39
|
+
loading: { type: Boolean, required: false },
|
|
40
|
+
loadingIcon: { type: String, required: false },
|
|
41
|
+
as: { type: null, required: false },
|
|
42
|
+
type: { type: null, required: false },
|
|
43
|
+
disabled: { type: Boolean, required: false },
|
|
44
|
+
active: { type: Boolean, required: false, default: void 0 },
|
|
45
|
+
exact: { type: Boolean, required: false },
|
|
46
|
+
exactQuery: { type: [Boolean, String], required: false },
|
|
47
|
+
exactHash: { type: Boolean, required: false },
|
|
48
|
+
inactiveClass: { type: String, required: false, default: "" },
|
|
49
|
+
to: { type: null, required: false },
|
|
50
|
+
href: { type: null, required: false },
|
|
51
|
+
external: { type: Boolean, required: false },
|
|
52
|
+
target: { type: [String, Object, null], required: false },
|
|
53
|
+
rel: { type: [String, Object, null], required: false },
|
|
54
|
+
noRel: { type: Boolean, required: false },
|
|
55
|
+
prefetchedClass: { type: String, required: false },
|
|
56
|
+
prefetch: { type: Boolean, required: false },
|
|
57
|
+
prefetchOn: { type: [String, Object], required: false },
|
|
58
|
+
noPrefetch: { type: Boolean, required: false },
|
|
59
|
+
activeClass: { type: String, required: false, default: "" },
|
|
60
|
+
exactActiveClass: { type: String, required: false },
|
|
61
|
+
ariaCurrentValue: { type: String, required: false },
|
|
62
|
+
viewTransition: { type: Boolean, required: false },
|
|
63
|
+
replace: { type: Boolean, required: false }
|
|
64
|
+
});
|
|
65
|
+
const slots = defineSlots();
|
|
66
|
+
const appConfig = useAppConfig();
|
|
67
|
+
const { orientation, size: buttonSize } = useButtonGroup(props);
|
|
68
|
+
const linkProps = useForwardProps(pickLinkProps(props));
|
|
69
|
+
const loadingAutoState = ref(false);
|
|
70
|
+
const formLoading = inject(formLoadingInjectionKey, void 0);
|
|
71
|
+
async function onClickWrapper(event) {
|
|
72
|
+
loadingAutoState.value = true;
|
|
73
|
+
const callbacks = Array.isArray(props.onClick) ? props.onClick : [props.onClick];
|
|
82
74
|
try {
|
|
83
|
-
await Promise.all(callbacks.map(fn => fn?.(event)))
|
|
75
|
+
await Promise.all(callbacks.map((fn) => fn?.(event)));
|
|
84
76
|
} finally {
|
|
85
|
-
loadingAutoState.value = false
|
|
77
|
+
loadingAutoState.value = false;
|
|
86
78
|
}
|
|
87
79
|
}
|
|
88
|
-
|
|
89
80
|
const isLoading = computed(() => {
|
|
90
|
-
return props.loading ||
|
|
91
|
-
})
|
|
92
|
-
|
|
81
|
+
return props.loading || props.loadingAuto && (loadingAutoState.value || formLoading?.value && props.type === "submit");
|
|
82
|
+
});
|
|
93
83
|
const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(
|
|
94
84
|
computed(() => ({ ...props, loading: isLoading.value }))
|
|
95
|
-
)
|
|
96
|
-
|
|
85
|
+
);
|
|
97
86
|
const ui = computed(() => tv({
|
|
98
|
-
extend:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
87
|
+
extend: tv(theme),
|
|
88
|
+
...defu({
|
|
89
|
+
variants: {
|
|
90
|
+
active: {
|
|
91
|
+
true: {
|
|
92
|
+
base: props.activeClass
|
|
93
|
+
},
|
|
94
|
+
false: {
|
|
95
|
+
base: props.inactiveClass
|
|
96
|
+
}
|
|
106
97
|
}
|
|
107
98
|
}
|
|
108
|
-
}
|
|
99
|
+
}, appConfig.ui?.button || {})
|
|
109
100
|
})({
|
|
110
101
|
color: props.color,
|
|
111
102
|
variant: props.variant,
|
|
112
103
|
size: buttonSize.value,
|
|
113
104
|
loading: isLoading.value,
|
|
114
105
|
block: props.block,
|
|
115
|
-
square: props.square ||
|
|
106
|
+
square: props.square || !slots.default && !props.label,
|
|
116
107
|
leading: isLeading.value,
|
|
117
108
|
trailing: isTrailing.value,
|
|
118
109
|
buttonGroup: orientation.value
|
|
119
|
-
}))
|
|
110
|
+
}));
|
|
120
111
|
</script>
|
|
121
112
|
|
|
122
113
|
<template>
|
|
@@ -131,16 +122,16 @@ const ui = computed(() => tv({
|
|
|
131
122
|
<ULinkBase
|
|
132
123
|
v-bind="slotProps"
|
|
133
124
|
:class="ui.base({
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
125
|
+
class: [props.class, props.ui?.base],
|
|
126
|
+
active,
|
|
127
|
+
...active && activeVariant ? { variant: activeVariant } : {},
|
|
128
|
+
...active && activeColor ? { color: activeColor } : {}
|
|
129
|
+
})"
|
|
139
130
|
@click="onClickWrapper"
|
|
140
131
|
>
|
|
141
132
|
<slot name="leading">
|
|
142
133
|
<UIcon v-if="isLeading && leadingIconName" :name="leadingIconName" :class="ui.leadingIcon({ class: props.ui?.leadingIcon, active })" />
|
|
143
|
-
<UAvatar v-else-if="!!avatar" :size="
|
|
134
|
+
<UAvatar v-else-if="!!avatar" :size="props.ui?.leadingAvatarSize || ui.leadingAvatarSize()" v-bind="avatar" :class="ui.leadingAvatar({ class: props.ui?.leadingAvatar, active })" />
|
|
144
135
|
</slot>
|
|
145
136
|
|
|
146
137
|
<slot>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import theme from '#build/ui/button';
|
|
3
|
+
import type { LinkProps } from './Link.vue';
|
|
4
|
+
import type { UseComponentIconsProps } from '../composables/useComponentIcons';
|
|
5
|
+
import type { ComponentConfig } from '../types/utils';
|
|
6
|
+
type Button = ComponentConfig<typeof theme, AppConfig, 'button'>;
|
|
7
|
+
export interface ButtonProps extends UseComponentIconsProps, Omit<LinkProps, 'raw' | 'custom'> {
|
|
8
|
+
label?: string;
|
|
9
|
+
/**
|
|
10
|
+
* @defaultValue 'primary'
|
|
11
|
+
*/
|
|
12
|
+
color?: Button['variants']['color'];
|
|
13
|
+
activeColor?: Button['variants']['color'];
|
|
14
|
+
/**
|
|
15
|
+
* @defaultValue 'solid'
|
|
16
|
+
*/
|
|
17
|
+
variant?: Button['variants']['variant'];
|
|
18
|
+
activeVariant?: Button['variants']['variant'];
|
|
19
|
+
/**
|
|
20
|
+
* @defaultValue 'md'
|
|
21
|
+
*/
|
|
22
|
+
size?: Button['variants']['size'];
|
|
23
|
+
/** Render the button with equal padding on all sides. */
|
|
24
|
+
square?: boolean;
|
|
25
|
+
/** Render the button full width. */
|
|
26
|
+
block?: boolean;
|
|
27
|
+
/** Set loading state automatically based on the `@click` promise state */
|
|
28
|
+
loadingAuto?: boolean;
|
|
29
|
+
onClick?: ((event: MouseEvent) => void | Promise<void>) | Array<((event: MouseEvent) => void | Promise<void>)>;
|
|
30
|
+
class?: any;
|
|
31
|
+
ui?: Button['slots'];
|
|
32
|
+
}
|
|
33
|
+
export interface ButtonSlots {
|
|
34
|
+
leading(props?: {}): any;
|
|
35
|
+
default(props?: {}): any;
|
|
36
|
+
trailing(props?: {}): any;
|
|
37
|
+
}
|
|
38
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ButtonProps>, {
|
|
39
|
+
active: undefined;
|
|
40
|
+
activeClass: string;
|
|
41
|
+
inactiveClass: string;
|
|
42
|
+
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ButtonProps>, {
|
|
43
|
+
active: undefined;
|
|
44
|
+
activeClass: string;
|
|
45
|
+
inactiveClass: string;
|
|
46
|
+
}>>> & Readonly<{}>, {
|
|
47
|
+
activeClass: string;
|
|
48
|
+
active: boolean;
|
|
49
|
+
inactiveClass: string;
|
|
50
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, Readonly<ButtonSlots> & ButtonSlots>;
|
|
51
|
+
export default _default;
|
|
52
|
+
type __VLS_WithDefaults<P, D> = {
|
|
53
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
54
|
+
default: D[K];
|
|
55
|
+
}> : P[K];
|
|
56
|
+
};
|
|
57
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
58
|
+
type __VLS_TypePropsToOption<T> = {
|
|
59
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
60
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
61
|
+
} : {
|
|
62
|
+
type: import('vue').PropType<T[K]>;
|
|
63
|
+
required: true;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
67
|
+
new (): {
|
|
68
|
+
$slots: S;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
type __VLS_PrettifyLocal<T> = {
|
|
72
|
+
[K in keyof T]: T[K];
|
|
73
|
+
} & {};
|
|
@@ -1,57 +1,31 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import type { AppConfig } from '@nuxt/schema'
|
|
4
|
-
import _appConfig from '#build/app.config'
|
|
5
|
-
import theme from '#build/ui/button-group'
|
|
6
|
-
import { tv } from '../utils/tv'
|
|
7
|
-
|
|
8
|
-
const appConfigButtonGroup = _appConfig as AppConfig & { ui: { buttonGroup: Partial<typeof theme> } }
|
|
9
|
-
|
|
10
|
-
const buttonGroup = tv({ extend: tv(theme), ...(appConfigButtonGroup.ui?.buttonGroup) })
|
|
11
|
-
|
|
12
|
-
type ButtonGroupVariants = VariantProps<typeof buttonGroup>
|
|
13
|
-
|
|
14
|
-
export interface ButtonGroupProps {
|
|
15
|
-
/**
|
|
16
|
-
* The element or component this component should render as.
|
|
17
|
-
* @defaultValue 'div'
|
|
18
|
-
*/
|
|
19
|
-
as?: any
|
|
20
|
-
/**
|
|
21
|
-
* @defaultValue 'md'
|
|
22
|
-
*/
|
|
23
|
-
size?: ButtonGroupVariants['size']
|
|
24
|
-
/**
|
|
25
|
-
* The orientation the buttons are laid out.
|
|
26
|
-
* @defaultValue 'horizontal'
|
|
27
|
-
*/
|
|
28
|
-
orientation?: ButtonGroupVariants['orientation']
|
|
29
|
-
class?: any
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface ButtonGroupSlots {
|
|
33
|
-
default(props?: {}): any
|
|
34
|
-
}
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui/button-group";
|
|
35
3
|
</script>
|
|
36
4
|
|
|
37
|
-
<script setup
|
|
38
|
-
import { provide, computed } from
|
|
39
|
-
import { Primitive } from
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { provide, computed } from "vue";
|
|
7
|
+
import { Primitive } from "reka-ui";
|
|
8
|
+
import { useAppConfig } from "#imports";
|
|
9
|
+
import { buttonGroupInjectionKey } from "../composables/useButtonGroup";
|
|
10
|
+
import { tv } from "../utils/tv";
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
as: { type: null, required: false },
|
|
13
|
+
size: { type: null, required: false },
|
|
14
|
+
orientation: { type: null, required: false, default: "horizontal" },
|
|
15
|
+
class: { type: null, required: false },
|
|
16
|
+
ui: { type: null, required: false }
|
|
17
|
+
});
|
|
18
|
+
defineSlots();
|
|
19
|
+
const appConfig = useAppConfig();
|
|
20
|
+
const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.buttonGroup || {} }));
|
|
47
21
|
provide(buttonGroupInjectionKey, computed(() => ({
|
|
48
22
|
orientation: props.orientation,
|
|
49
23
|
size: props.size
|
|
50
|
-
})))
|
|
24
|
+
})));
|
|
51
25
|
</script>
|
|
52
26
|
|
|
53
27
|
<template>
|
|
54
|
-
<Primitive :as="as" :class="
|
|
28
|
+
<Primitive :as="as" :class="ui({ orientation, class: props.class })">
|
|
55
29
|
<slot />
|
|
56
30
|
</Primitive>
|
|
57
31
|
</template>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import theme from '#build/ui/button-group';
|
|
3
|
+
import type { ComponentConfig } from '../types/utils';
|
|
4
|
+
type ButtonGroup = ComponentConfig<typeof theme, AppConfig, 'buttonGroup'>;
|
|
5
|
+
export interface ButtonGroupProps {
|
|
6
|
+
/**
|
|
7
|
+
* The element or component this component should render as.
|
|
8
|
+
* @defaultValue 'div'
|
|
9
|
+
*/
|
|
10
|
+
as?: any;
|
|
11
|
+
/**
|
|
12
|
+
* @defaultValue 'md'
|
|
13
|
+
*/
|
|
14
|
+
size?: ButtonGroup['variants']['size'];
|
|
15
|
+
/**
|
|
16
|
+
* The orientation the buttons are laid out.
|
|
17
|
+
* @defaultValue 'horizontal'
|
|
18
|
+
*/
|
|
19
|
+
orientation?: ButtonGroup['variants']['orientation'];
|
|
20
|
+
class?: any;
|
|
21
|
+
ui?: ButtonGroup['slots'];
|
|
22
|
+
}
|
|
23
|
+
export interface ButtonGroupSlots {
|
|
24
|
+
default(props?: {}): any;
|
|
25
|
+
}
|
|
26
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ButtonGroupProps>, {
|
|
27
|
+
orientation: string;
|
|
28
|
+
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ButtonGroupProps>, {
|
|
29
|
+
orientation: string;
|
|
30
|
+
}>>> & Readonly<{}>, {
|
|
31
|
+
orientation: ButtonGroup["variants"]["orientation"];
|
|
32
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, Readonly<ButtonGroupSlots> & ButtonGroupSlots>;
|
|
33
|
+
export default _default;
|
|
34
|
+
type __VLS_WithDefaults<P, D> = {
|
|
35
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
36
|
+
default: D[K];
|
|
37
|
+
}> : P[K];
|
|
38
|
+
};
|
|
39
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
40
|
+
type __VLS_TypePropsToOption<T> = {
|
|
41
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
42
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
43
|
+
} : {
|
|
44
|
+
type: import('vue').PropType<T[K]>;
|
|
45
|
+
required: true;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
49
|
+
new (): {
|
|
50
|
+
$slots: S;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
type __VLS_PrettifyLocal<T> = {
|
|
54
|
+
[K in keyof T]: T[K];
|
|
55
|
+
} & {};
|