@nuxt/ui 3.0.1 → 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 +24 -3
- 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 +103 -84
- 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 +44 -23
- 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.d.mts +2 -1
- package/dist/module.json +5 -5
- package/dist/module.mjs +11 -7
- package/dist/runtime/components/Accordion.vue +36 -92
- 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 +47 -78
- 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 +36 -88
- package/dist/runtime/components/Breadcrumb.vue.d.ts +82 -0
- package/dist/runtime/components/Button.vue +96 -105
- 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 +73 -127
- 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 -230
- 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 +94 -234
- 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 +32 -119
- package/dist/runtime/components/ContextMenu.vue.d.ts +127 -0
- package/dist/runtime/components/ContextMenuContent.vue +71 -72
- package/dist/runtime/components/ContextMenuContent.vue.d.ts +105 -0
- package/dist/runtime/components/Drawer.vue +49 -87
- package/dist/runtime/components/Drawer.vue.d.ts +88 -0
- package/dist/runtime/components/DropdownMenu.vue +37 -129
- package/dist/runtime/components/DropdownMenu.vue.d.ts +141 -0
- package/dist/runtime/components/DropdownMenuContent.vue +76 -79
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +55 -0
- package/dist/runtime/components/Form.vue +135 -219
- package/dist/runtime/components/Form.vue.d.ts +66 -0
- package/dist/runtime/components/FormField.vue +36 -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 +193 -302
- 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 -173
- package/dist/runtime/components/Link.vue.d.ts +124 -0
- package/dist/runtime/components/LinkBase.vue +33 -41
- 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 +78 -186
- 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 +75 -126
- package/dist/runtime/components/RadioGroup.vue.d.ts +88 -0
- package/dist/runtime/components/Select.vue +115 -202
- package/dist/runtime/components/Select.vue.d.ts +139 -0
- package/dist/runtime/components/SelectMenu.vue +167 -281
- 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 +44 -113
- 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 +165 -264
- package/dist/runtime/components/Table.vue.d.ts +183 -0
- package/dist/runtime/components/Tabs.vue +40 -105
- 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 +57 -150
- package/dist/runtime/components/Tree.vue.d.ts +128 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
- package/dist/runtime/composables/defineShortcuts.js +0 -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/useFormField.js +1 -1
- package/dist/runtime/composables/useOverlay.d.ts +16 -8
- 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/hy.d.ts +3 -0
- package/dist/runtime/locale/hy.js +54 -0
- package/dist/runtime/locale/index.d.ts +6 -1
- package/dist/runtime/locale/index.js +6 -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 +5 -1
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/index.js +2 -0
- package/dist/runtime/types/utils.d.ts +70 -10
- package/dist/runtime/utils/index.d.ts +1 -0
- package/dist/runtime/utils/index.js +3 -0
- package/dist/runtime/utils/link.d.ts +4 -27
- package/dist/runtime/utils/link.js +32 -1
- 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 -199
- package/dist/runtime/vue/components/Link.vue.d.ts +124 -0
- package/dist/runtime/vue/stubs.d.ts +5 -0
- package/dist/runtime/vue/stubs.js +11 -2
- package/dist/shared/{ui.BCaWD5Ek.mjs → ui.D7lOOabO.mjs} +623 -364
- package/dist/types.d.mts +5 -1
- package/dist/unplugin.d.mts +6 -1
- package/dist/unplugin.mjs +25 -4
- package/dist/vite.mjs +1 -1
- package/package.json +122 -64
- package/dist/module.cjs +0 -62
- package/dist/module.d.cts +0 -44
- package/dist/module.d.ts +0 -44
- package/dist/shared/ui.C6uTSFTI.cjs +0 -3555
- package/dist/types.d.ts +0 -1
- package/dist/unplugin.cjs +0 -232
- package/dist/unplugin.d.cts +0 -61
- package/dist/unplugin.d.ts +0 -61
- package/dist/vite.cjs +0 -23
- package/dist/vite.d.cts +0 -15
- package/dist/vite.d.ts +0 -15
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import theme from '#build/ui/form-field';
|
|
3
|
+
import type { ComponentConfig } from '../types/utils';
|
|
4
|
+
type FormField = ComponentConfig<typeof theme, AppConfig, 'formField'>;
|
|
5
|
+
export interface FormFieldProps {
|
|
6
|
+
/**
|
|
7
|
+
* The element or component this component should render as.
|
|
8
|
+
* @defaultValue 'div'
|
|
9
|
+
*/
|
|
10
|
+
as?: any;
|
|
11
|
+
/** The name of the FormField. Also used to match form errors. */
|
|
12
|
+
name?: string;
|
|
13
|
+
/** A regular expression to match form error names. */
|
|
14
|
+
errorPattern?: RegExp;
|
|
15
|
+
label?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
help?: string;
|
|
18
|
+
error?: string | boolean;
|
|
19
|
+
hint?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @defaultValue 'md'
|
|
22
|
+
*/
|
|
23
|
+
size?: FormField['variants']['size'];
|
|
24
|
+
required?: boolean;
|
|
25
|
+
/** If true, validation on input will be active immediately instead of waiting for a blur event. */
|
|
26
|
+
eagerValidation?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Delay in milliseconds before validating the form on input events.
|
|
29
|
+
* @defaultValue `300`
|
|
30
|
+
*/
|
|
31
|
+
validateOnInputDelay?: number;
|
|
32
|
+
class?: any;
|
|
33
|
+
ui?: FormField['slots'];
|
|
34
|
+
}
|
|
35
|
+
export interface FormFieldSlots {
|
|
36
|
+
label(props: {
|
|
37
|
+
label?: string;
|
|
38
|
+
}): any;
|
|
39
|
+
hint(props: {
|
|
40
|
+
hint?: string;
|
|
41
|
+
}): any;
|
|
42
|
+
description(props: {
|
|
43
|
+
description?: string;
|
|
44
|
+
}): any;
|
|
45
|
+
help(props: {
|
|
46
|
+
help?: string;
|
|
47
|
+
}): any;
|
|
48
|
+
error(props: {
|
|
49
|
+
error?: string | boolean;
|
|
50
|
+
}): any;
|
|
51
|
+
default(props: {
|
|
52
|
+
error?: string | boolean;
|
|
53
|
+
}): any;
|
|
54
|
+
}
|
|
55
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<FormFieldProps>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<FormFieldProps>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, Readonly<FormFieldSlots> & FormFieldSlots>;
|
|
56
|
+
export default _default;
|
|
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
|
+
};
|
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
<script
|
|
2
|
-
export interface IconProps {
|
|
3
|
-
name: string
|
|
4
|
-
mode?: 'svg' | 'css'
|
|
5
|
-
size?: string | number
|
|
6
|
-
customize?: (
|
|
7
|
-
content: string,
|
|
8
|
-
name?: string,
|
|
9
|
-
prefix?: string,
|
|
10
|
-
provider?: string
|
|
11
|
-
) => string
|
|
12
|
-
}
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
import { useForwardProps } from 'reka-ui'
|
|
17
|
-
import { reactivePick } from '@vueuse/core'
|
|
1
|
+
<script>
|
|
18
2
|
|
|
19
|
-
|
|
3
|
+
</script>
|
|
20
4
|
|
|
21
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { useForwardProps } from "reka-ui";
|
|
7
|
+
import { reactivePick } from "@vueuse/core";
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
name: { type: String, required: true },
|
|
10
|
+
mode: { type: String, required: false },
|
|
11
|
+
size: { type: [String, Number], required: false },
|
|
12
|
+
customize: { type: Function, required: false }
|
|
13
|
+
});
|
|
14
|
+
const iconProps = useForwardProps(reactivePick(props, "name", "mode", "size", "customize"));
|
|
22
15
|
</script>
|
|
23
16
|
|
|
24
17
|
<template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface IconProps {
|
|
2
|
+
name: string;
|
|
3
|
+
mode?: 'svg' | 'css';
|
|
4
|
+
size?: string | number;
|
|
5
|
+
customize?: (content: string, name?: string, prefix?: string, provider?: string) => string;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<IconProps>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<IconProps>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
export default _default;
|
|
9
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
10
|
+
type __VLS_TypePropsToOption<T> = {
|
|
11
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
12
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
13
|
+
} : {
|
|
14
|
+
type: import('vue').PropType<T[K]>;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -1,97 +1,55 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import type { VariantProps } from 'tailwind-variants'
|
|
4
|
-
import type { AppConfig } from '@nuxt/schema'
|
|
5
|
-
import _appConfig from '#build/app.config'
|
|
6
|
-
import theme from '#build/ui/input'
|
|
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 appConfigInput = _appConfig as AppConfig & { ui: { input: Partial<typeof theme> } }
|
|
13
|
-
|
|
14
|
-
const input = tv({ extend: tv(theme), ...(appConfigInput.ui?.input || {}) })
|
|
15
|
-
|
|
16
|
-
type InputVariants = VariantProps<typeof input>
|
|
17
|
-
|
|
18
|
-
export interface InputProps extends UseComponentIconsProps {
|
|
19
|
-
/**
|
|
20
|
-
* The element or component this component should render as.
|
|
21
|
-
* @defaultValue 'div'
|
|
22
|
-
*/
|
|
23
|
-
as?: any
|
|
24
|
-
id?: string
|
|
25
|
-
name?: string
|
|
26
|
-
type?: InputHTMLAttributes['type']
|
|
27
|
-
/** The placeholder text when the input is empty. */
|
|
28
|
-
placeholder?: string
|
|
29
|
-
/**
|
|
30
|
-
* @defaultValue 'primary'
|
|
31
|
-
*/
|
|
32
|
-
color?: InputVariants['color']
|
|
33
|
-
/**
|
|
34
|
-
* @defaultValue 'outline'
|
|
35
|
-
*/
|
|
36
|
-
variant?: InputVariants['variant']
|
|
37
|
-
/**
|
|
38
|
-
* @defaultValue 'md'
|
|
39
|
-
*/
|
|
40
|
-
size?: InputVariants['size']
|
|
41
|
-
required?: boolean
|
|
42
|
-
autocomplete?: InputHTMLAttributes['autocomplete']
|
|
43
|
-
autofocus?: boolean
|
|
44
|
-
autofocusDelay?: number
|
|
45
|
-
disabled?: boolean
|
|
46
|
-
/** Highlight the ring color like a focus state. */
|
|
47
|
-
highlight?: boolean
|
|
48
|
-
class?: any
|
|
49
|
-
ui?: PartialString<typeof input.slots>
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface InputEmits {
|
|
53
|
-
(e: 'update:modelValue', payload: string | number): void
|
|
54
|
-
(e: 'blur', event: FocusEvent): void
|
|
55
|
-
(e: 'change', event: Event): void
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface InputSlots {
|
|
59
|
-
leading(props?: {}): any
|
|
60
|
-
default(props?: {}): any
|
|
61
|
-
trailing(props?: {}): any
|
|
62
|
-
}
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui/input";
|
|
63
3
|
</script>
|
|
64
4
|
|
|
65
|
-
<script setup
|
|
66
|
-
import { ref, computed, onMounted } from
|
|
67
|
-
import { Primitive } from
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import
|
|
73
|
-
import
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const props =
|
|
78
|
-
type:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { ref, computed, onMounted } from "vue";
|
|
7
|
+
import { Primitive } from "reka-ui";
|
|
8
|
+
import { useAppConfig } from "#imports";
|
|
9
|
+
import { useButtonGroup } from "../composables/useButtonGroup";
|
|
10
|
+
import { useComponentIcons } from "../composables/useComponentIcons";
|
|
11
|
+
import { useFormField } from "../composables/useFormField";
|
|
12
|
+
import { looseToNumber } from "../utils";
|
|
13
|
+
import { tv } from "../utils/tv";
|
|
14
|
+
import UIcon from "./Icon.vue";
|
|
15
|
+
import UAvatar from "./Avatar.vue";
|
|
16
|
+
defineOptions({ inheritAttrs: false });
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
as: { type: null, required: false },
|
|
19
|
+
id: { type: String, required: false },
|
|
20
|
+
name: { type: String, required: false },
|
|
21
|
+
type: { type: null, required: false, default: "text" },
|
|
22
|
+
placeholder: { type: String, required: false },
|
|
23
|
+
color: { type: null, required: false },
|
|
24
|
+
variant: { type: null, required: false },
|
|
25
|
+
size: { type: null, required: false },
|
|
26
|
+
required: { type: Boolean, required: false },
|
|
27
|
+
autocomplete: { type: null, required: false, default: "off" },
|
|
28
|
+
autofocus: { type: Boolean, required: false },
|
|
29
|
+
autofocusDelay: { type: Number, required: false, default: 0 },
|
|
30
|
+
disabled: { type: Boolean, required: false },
|
|
31
|
+
highlight: { type: Boolean, required: false },
|
|
32
|
+
class: { type: null, required: false },
|
|
33
|
+
ui: { type: null, required: false },
|
|
34
|
+
icon: { type: String, required: false },
|
|
35
|
+
avatar: { type: Object, required: false },
|
|
36
|
+
leading: { type: Boolean, required: false },
|
|
37
|
+
leadingIcon: { type: String, required: false },
|
|
38
|
+
trailing: { type: Boolean, required: false },
|
|
39
|
+
trailingIcon: { type: String, required: false },
|
|
40
|
+
loading: { type: Boolean, required: false },
|
|
41
|
+
loadingIcon: { type: String, required: false }
|
|
42
|
+
});
|
|
43
|
+
const emits = defineEmits(["update:modelValue", "blur", "change"]);
|
|
44
|
+
const slots = defineSlots();
|
|
45
|
+
const [modelValue, modelModifiers] = defineModel({ type: [String, Number, null] });
|
|
46
|
+
const appConfig = useAppConfig();
|
|
47
|
+
const { emitFormBlur, emitFormInput, emitFormChange, size: formGroupSize, color, id, name, highlight, disabled, emitFormFocus, ariaAttrs } = useFormField(props, { deferInputValidation: true });
|
|
48
|
+
const { orientation, size: buttonGroupSize } = useButtonGroup(props);
|
|
49
|
+
const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(props);
|
|
50
|
+
const inputSize = computed(() => buttonGroupSize.value || formGroupSize.value);
|
|
51
|
+
const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.input || {} })({
|
|
52
|
+
type: props.type,
|
|
95
53
|
color: color.value,
|
|
96
54
|
variant: props.variant,
|
|
97
55
|
size: inputSize?.value,
|
|
@@ -100,70 +58,54 @@ const ui = computed(() => input({
|
|
|
100
58
|
leading: isLeading.value || !!props.avatar || !!slots.leading,
|
|
101
59
|
trailing: isTrailing.value || !!slots.trailing,
|
|
102
60
|
buttonGroup: orientation.value
|
|
103
|
-
}))
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
function autoFocus() {
|
|
108
|
-
if (props.autofocus) {
|
|
109
|
-
inputRef.value?.focus()
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Custom function to handle the v-model properties
|
|
114
|
-
function updateInput(value: string | null) {
|
|
61
|
+
}));
|
|
62
|
+
const inputRef = ref(null);
|
|
63
|
+
function updateInput(value) {
|
|
115
64
|
if (modelModifiers.trim) {
|
|
116
|
-
value = value?.trim() ?? null
|
|
65
|
+
value = value?.trim() ?? null;
|
|
117
66
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
value = looseToNumber(value)
|
|
67
|
+
if (modelModifiers.number || props.type === "number") {
|
|
68
|
+
value = looseToNumber(value);
|
|
121
69
|
}
|
|
122
|
-
|
|
123
70
|
if (modelModifiers.nullify) {
|
|
124
|
-
value ||= null
|
|
71
|
+
value ||= null;
|
|
125
72
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
emitFormInput()
|
|
73
|
+
modelValue.value = value;
|
|
74
|
+
emitFormInput();
|
|
129
75
|
}
|
|
130
|
-
|
|
131
|
-
function onInput(event: Event) {
|
|
76
|
+
function onInput(event) {
|
|
132
77
|
if (!modelModifiers.lazy) {
|
|
133
|
-
updateInput(
|
|
78
|
+
updateInput(event.target.value);
|
|
134
79
|
}
|
|
135
80
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const value = (event.target as HTMLInputElement).value
|
|
139
|
-
|
|
81
|
+
function onChange(event) {
|
|
82
|
+
const value = event.target.value;
|
|
140
83
|
if (modelModifiers.lazy) {
|
|
141
|
-
updateInput(value)
|
|
84
|
+
updateInput(value);
|
|
142
85
|
}
|
|
143
|
-
|
|
144
|
-
// Update trimmed input so that it has same behavior as native input https://github.com/vuejs/core/blob/5ea8a8a4fab4e19a71e123e4d27d051f5e927172/packages/runtime-dom/src/directives/vModel.ts#L63
|
|
145
86
|
if (modelModifiers.trim) {
|
|
146
|
-
|
|
87
|
+
event.target.value = value.trim();
|
|
147
88
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
emits('change', event)
|
|
89
|
+
emitFormChange();
|
|
90
|
+
emits("change", event);
|
|
151
91
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
92
|
+
function onBlur(event) {
|
|
93
|
+
emitFormBlur();
|
|
94
|
+
emits("blur", event);
|
|
95
|
+
}
|
|
96
|
+
function autoFocus() {
|
|
97
|
+
if (props.autofocus) {
|
|
98
|
+
inputRef.value?.focus();
|
|
99
|
+
}
|
|
156
100
|
}
|
|
157
|
-
|
|
158
|
-
defineExpose({
|
|
159
|
-
inputRef
|
|
160
|
-
})
|
|
161
|
-
|
|
162
101
|
onMounted(() => {
|
|
163
102
|
setTimeout(() => {
|
|
164
|
-
autoFocus()
|
|
165
|
-
}, props.autofocusDelay)
|
|
166
|
-
})
|
|
103
|
+
autoFocus();
|
|
104
|
+
}, props.autofocusDelay);
|
|
105
|
+
});
|
|
106
|
+
defineExpose({
|
|
107
|
+
inputRef
|
|
108
|
+
});
|
|
167
109
|
</script>
|
|
168
110
|
|
|
169
111
|
<template>
|
|
@@ -191,7 +133,7 @@ onMounted(() => {
|
|
|
191
133
|
<span v-if="isLeading || !!avatar || !!slots.leading" :class="ui.leading({ class: props.ui?.leading })">
|
|
192
134
|
<slot name="leading">
|
|
193
135
|
<UIcon v-if="isLeading && leadingIconName" :name="leadingIconName" :class="ui.leadingIcon({ class: props.ui?.leadingIcon })" />
|
|
194
|
-
<UAvatar v-else-if="!!avatar" :size="
|
|
136
|
+
<UAvatar v-else-if="!!avatar" :size="props.ui?.leadingAvatarSize || ui.leadingAvatarSize()" v-bind="avatar" :class="ui.leadingAvatar({ class: props.ui?.leadingAvatar })" />
|
|
195
137
|
</slot>
|
|
196
138
|
</span>
|
|
197
139
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from 'vue';
|
|
2
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
3
|
+
import theme from '#build/ui/input';
|
|
4
|
+
import type { UseComponentIconsProps } from '../composables/useComponentIcons';
|
|
5
|
+
import type { ComponentConfig } from '../types/utils';
|
|
6
|
+
type Input = ComponentConfig<typeof theme, AppConfig, 'input'>;
|
|
7
|
+
export interface InputProps extends UseComponentIconsProps {
|
|
8
|
+
/**
|
|
9
|
+
* The element or component this component should render as.
|
|
10
|
+
* @defaultValue 'div'
|
|
11
|
+
*/
|
|
12
|
+
as?: any;
|
|
13
|
+
id?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
type?: InputHTMLAttributes['type'];
|
|
16
|
+
/** The placeholder text when the input is empty. */
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
/**
|
|
19
|
+
* @defaultValue 'primary'
|
|
20
|
+
*/
|
|
21
|
+
color?: Input['variants']['color'];
|
|
22
|
+
/**
|
|
23
|
+
* @defaultValue 'outline'
|
|
24
|
+
*/
|
|
25
|
+
variant?: Input['variants']['variant'];
|
|
26
|
+
/**
|
|
27
|
+
* @defaultValue 'md'
|
|
28
|
+
*/
|
|
29
|
+
size?: Input['variants']['size'];
|
|
30
|
+
required?: boolean;
|
|
31
|
+
autocomplete?: InputHTMLAttributes['autocomplete'];
|
|
32
|
+
autofocus?: boolean;
|
|
33
|
+
autofocusDelay?: number;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/** Highlight the ring color like a focus state. */
|
|
36
|
+
highlight?: boolean;
|
|
37
|
+
class?: any;
|
|
38
|
+
ui?: Input['slots'];
|
|
39
|
+
}
|
|
40
|
+
export interface InputEmits {
|
|
41
|
+
(e: 'update:modelValue', payload: string | number): void;
|
|
42
|
+
(e: 'blur', event: FocusEvent): void;
|
|
43
|
+
(e: 'change', event: Event): void;
|
|
44
|
+
}
|
|
45
|
+
export interface InputSlots {
|
|
46
|
+
leading(props?: {}): any;
|
|
47
|
+
default(props?: {}): any;
|
|
48
|
+
trailing(props?: {}): any;
|
|
49
|
+
}
|
|
50
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
51
|
+
modelValue?: string | number | null;
|
|
52
|
+
} & InputProps>, {
|
|
53
|
+
type: string;
|
|
54
|
+
autocomplete: string;
|
|
55
|
+
autofocusDelay: number;
|
|
56
|
+
}>>, {
|
|
57
|
+
inputRef: import("vue").Ref<HTMLInputElement | null, HTMLInputElement | null>;
|
|
58
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
59
|
+
modelValue?: string | number | null;
|
|
60
|
+
} & InputProps>, {
|
|
61
|
+
type: string;
|
|
62
|
+
autocomplete: string;
|
|
63
|
+
autofocusDelay: number;
|
|
64
|
+
}>>> & Readonly<{}>, {
|
|
65
|
+
type: import("vue").InputTypeHTMLAttribute;
|
|
66
|
+
autocomplete: string;
|
|
67
|
+
autofocusDelay: number;
|
|
68
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, Readonly<InputSlots> & InputSlots>;
|
|
69
|
+
export default _default;
|
|
70
|
+
type __VLS_WithDefaults<P, D> = {
|
|
71
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
72
|
+
default: D[K];
|
|
73
|
+
}> : P[K];
|
|
74
|
+
};
|
|
75
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
76
|
+
type __VLS_TypePropsToOption<T> = {
|
|
77
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
78
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
79
|
+
} : {
|
|
80
|
+
type: import('vue').PropType<T[K]>;
|
|
81
|
+
required: true;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
85
|
+
new (): {
|
|
86
|
+
$slots: S;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
type __VLS_PrettifyLocal<T> = {
|
|
90
|
+
[K in keyof T]: T[K];
|
|
91
|
+
} & {};
|