@byyuurin/ui 0.0.10 → 0.0.11
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 +2 -2
- package/dist/module.json +3 -3
- package/dist/module.mjs +1 -1
- package/dist/module.mjs.map +1 -1
- package/dist/runtime/app/injections.d.ts +388 -364
- package/dist/runtime/components/Accordion.vue +38 -67
- package/dist/runtime/components/Accordion.vue.d.ts +52 -0
- package/dist/runtime/components/Alert.vue +37 -75
- package/dist/runtime/components/Alert.vue.d.ts +59 -0
- package/dist/runtime/components/App.vue +25 -40
- package/dist/runtime/components/App.vue.d.ts +24 -0
- package/dist/runtime/components/Avatar.vue +31 -51
- package/dist/runtime/components/Avatar.vue.d.ts +25 -0
- package/dist/runtime/components/AvatarGroup.vue +38 -69
- package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
- package/dist/runtime/components/Badge.vue +25 -51
- package/dist/runtime/components/Badge.vue.d.ts +44 -0
- package/dist/runtime/components/Breadcrumb.vue +36 -74
- package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
- package/dist/runtime/components/Button.vue +62 -51
- package/dist/runtime/components/Button.vue.d.ts +29 -0
- package/dist/runtime/components/ButtonGroup.vue +17 -37
- package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
- package/dist/runtime/components/Calendar.vue +75 -110
- package/dist/runtime/components/Calendar.vue.d.ts +75 -0
- package/dist/runtime/components/Card.vue +25 -42
- package/dist/runtime/components/Card.vue.d.ts +30 -0
- package/dist/runtime/components/Carousel.vue +118 -225
- package/dist/runtime/components/Carousel.vue.d.ts +104 -0
- package/dist/runtime/components/Checkbox.vue +46 -73
- package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
- package/dist/runtime/components/Chip.vue +31 -48
- package/dist/runtime/components/Chip.vue.d.ts +30 -0
- package/dist/runtime/components/Collapsible.vue +22 -30
- package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
- package/dist/runtime/components/Drawer.vue +51 -101
- package/dist/runtime/components/Drawer.vue.d.ts +80 -0
- package/dist/runtime/components/DropdownMenu.vue +37 -115
- package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
- package/dist/runtime/components/DropdownMenuContent.vue +81 -77
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
- package/dist/runtime/components/Form.vue +140 -254
- package/dist/runtime/components/Form.vue.d.ts +78 -0
- package/dist/runtime/components/FormItem.vue +50 -89
- package/dist/runtime/components/FormItem.vue.d.ts +60 -0
- package/dist/runtime/components/Input.vue +79 -115
- package/dist/runtime/components/Input.vue.d.ts +64 -0
- package/dist/runtime/components/InputNumber.vue +74 -117
- package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
- package/dist/runtime/components/Kbd.vue +18 -39
- package/dist/runtime/components/Kbd.vue.d.ts +28 -0
- package/dist/runtime/components/Link.vue +168 -257
- package/dist/runtime/components/Link.vue.d.ts +95 -0
- package/dist/runtime/components/LinkBase.vue +36 -54
- package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
- package/dist/runtime/components/Modal.vue +49 -84
- package/dist/runtime/components/Modal.vue.d.ts +66 -0
- package/dist/runtime/components/OverlayProvider.vue +10 -14
- package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
- package/dist/runtime/components/Pagination.vue +55 -121
- package/dist/runtime/components/Pagination.vue.d.ts +93 -0
- package/dist/runtime/components/PinInput.vue +49 -58
- package/dist/runtime/components/PinInput.vue.d.ts +35 -0
- package/dist/runtime/components/Popover.vue +39 -68
- package/dist/runtime/components/Popover.vue.d.ts +45 -0
- package/dist/runtime/components/Progress.vue +68 -120
- package/dist/runtime/components/Progress.vue.d.ts +54 -0
- package/dist/runtime/components/RadioGroup.vue +67 -125
- package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
- package/dist/runtime/components/ScrollArea.vue +31 -31
- package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
- package/dist/runtime/components/Select.vue +114 -204
- package/dist/runtime/components/Select.vue.d.ts +119 -0
- package/dist/runtime/components/Separator.vue +26 -44
- package/dist/runtime/components/Separator.vue.d.ts +27 -0
- package/dist/runtime/components/Skeleton.vue +12 -21
- package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
- package/dist/runtime/components/Slider.vue +52 -74
- package/dist/runtime/components/Slider.vue.d.ts +36 -0
- package/dist/runtime/components/Switch.vue +51 -71
- package/dist/runtime/components/Switch.vue.d.ts +49 -0
- package/dist/runtime/components/Table.vue +108 -194
- package/dist/runtime/components/Table.vue.d.ts +148 -0
- package/dist/runtime/components/Tabs.vue +36 -81
- package/dist/runtime/components/Tabs.vue.d.ts +65 -0
- package/dist/runtime/components/Textarea.vue +77 -124
- package/dist/runtime/components/Textarea.vue.d.ts +60 -0
- package/dist/runtime/components/Toast.vue +47 -75
- package/dist/runtime/components/Toast.vue.d.ts +131 -0
- package/dist/runtime/components/ToastProvider.vue +65 -101
- package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
- package/dist/runtime/components/Tooltip.vue +36 -47
- package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
- package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
- package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
- package/dist/runtime/composables/useFormItem.d.ts +2 -2
- package/dist/runtime/composables/useKbd.d.ts +1 -1
- package/dist/runtime/composables/useLocale.d.ts +3 -3
- package/dist/runtime/composables/useTheme.d.ts +1 -1
- package/dist/runtime/composables/useToast.d.ts +1 -1
- package/dist/runtime/locale/en.d.ts +1 -1
- package/dist/runtime/locale/zh-tw.d.ts +1 -1
- package/dist/runtime/theme/accordion.d.ts +45 -51
- package/dist/runtime/theme/accordion.js +1 -1
- package/dist/runtime/theme/alert.d.ts +115 -121
- package/dist/runtime/theme/alert.js +1 -1
- package/dist/runtime/theme/avatar-group.d.ts +42 -48
- package/dist/runtime/theme/avatar-group.js +1 -1
- package/dist/runtime/theme/avatar.d.ts +46 -52
- package/dist/runtime/theme/avatar.js +1 -1
- package/dist/runtime/theme/badge.d.ts +60 -66
- package/dist/runtime/theme/badge.js +1 -1
- package/dist/runtime/theme/breadcrumb.d.ts +52 -58
- package/dist/runtime/theme/breadcrumb.js +1 -1
- package/dist/runtime/theme/button-group.d.ts +36 -42
- package/dist/runtime/theme/button.d.ts +162 -168
- package/dist/runtime/theme/button.js +1 -1
- package/dist/runtime/theme/calendar.d.ts +52 -50
- package/dist/runtime/theme/calendar.js +20 -3
- package/dist/runtime/theme/card.d.ts +52 -58
- package/dist/runtime/theme/card.js +1 -1
- package/dist/runtime/theme/carousel.d.ts +98 -104
- package/dist/runtime/theme/carousel.js +1 -1
- package/dist/runtime/theme/checkbox.d.ts +77 -83
- package/dist/runtime/theme/checkbox.js +1 -1
- package/dist/runtime/theme/chip.d.ts +50 -56
- package/dist/runtime/theme/chip.js +1 -1
- package/dist/runtime/theme/collapsible.d.ts +29 -35
- package/dist/runtime/theme/collapsible.js +1 -1
- package/dist/runtime/theme/drawer.d.ts +120 -126
- package/dist/runtime/theme/drawer.js +1 -1
- package/dist/runtime/theme/dropdown-menu.d.ts +55 -61
- package/dist/runtime/theme/dropdown-menu.js +1 -1
- package/dist/runtime/theme/form-item.d.ts +63 -69
- package/dist/runtime/theme/form-item.js +1 -1
- package/dist/runtime/theme/form.d.ts +1 -7
- package/dist/runtime/theme/input-number.d.ts +98 -104
- package/dist/runtime/theme/input-number.js +1 -1
- package/dist/runtime/theme/input.d.ts +153 -159
- package/dist/runtime/theme/input.js +1 -1
- package/dist/runtime/theme/kbd.d.ts +30 -36
- package/dist/runtime/theme/link.d.ts +37 -43
- package/dist/runtime/theme/modal.d.ts +36 -42
- package/dist/runtime/theme/modal.js +1 -1
- package/dist/runtime/theme/pagination.d.ts +71 -77
- package/dist/runtime/theme/pagination.js +1 -1
- package/dist/runtime/theme/pinInput.d.ts +80 -86
- package/dist/runtime/theme/pinInput.js +1 -1
- package/dist/runtime/theme/popover.d.ts +29 -35
- package/dist/runtime/theme/popover.js +1 -1
- package/dist/runtime/theme/progress.d.ts +163 -169
- package/dist/runtime/theme/progress.js +1 -1
- package/dist/runtime/theme/radio-group.d.ts +99 -105
- package/dist/runtime/theme/radio-group.js +1 -1
- package/dist/runtime/theme/scroll-area.d.ts +62 -68
- package/dist/runtime/theme/scroll-area.js +1 -1
- package/dist/runtime/theme/select.d.ts +165 -171
- package/dist/runtime/theme/select.js +1 -1
- package/dist/runtime/theme/separator.d.ts +62 -68
- package/dist/runtime/theme/separator.js +1 -1
- package/dist/runtime/theme/skeleton.d.ts +1 -7
- package/dist/runtime/theme/slider.d.ts +62 -68
- package/dist/runtime/theme/slider.js +1 -1
- package/dist/runtime/theme/switch.d.ts +111 -117
- package/dist/runtime/theme/switch.js +1 -1
- package/dist/runtime/theme/table.d.ts +75 -81
- package/dist/runtime/theme/table.js +1 -1
- package/dist/runtime/theme/tabs.d.ts +114 -120
- package/dist/runtime/theme/tabs.js +1 -1
- package/dist/runtime/theme/textarea.d.ts +76 -82
- package/dist/runtime/theme/textarea.js +1 -1
- package/dist/runtime/theme/toast-provider.d.ts +106 -112
- package/dist/runtime/theme/toast-provider.js +1 -1
- package/dist/runtime/theme/toast.d.ts +74 -80
- package/dist/runtime/theme/toast.js +1 -1
- package/dist/runtime/theme/tooltip.d.ts +35 -41
- package/dist/runtime/theme/tooltip.js +1 -1
- package/dist/runtime/types/utils.d.ts +5 -5
- package/dist/runtime/utils/link.d.ts +3 -5
- package/dist/runtime/utils/styler.d.ts +2 -2
- package/dist/runtime/utils/styler.js +2 -2
- package/dist/shared/ui.D1BTWZFB.mjs +5 -0
- package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
- package/dist/types.d.mts +1 -1
- package/dist/unocss.mjs +5 -4
- package/dist/unocss.mjs.map +1 -1
- package/dist/unplugin.mjs +1 -1
- package/dist/unplugin.mjs.map +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +77 -75
- package/dist/module.cjs +0 -5
- package/dist/shared/ui.3e7fad19.mjs +0 -5
- package/dist/shared/ui.3e7fad19.mjs.map +0 -1
- package/dist/types.d.ts +0 -1
|
@@ -1,125 +1,86 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
-
import type { PrimitiveProps } from 'reka-ui'
|
|
4
|
-
import type { formItem } from '../theme'
|
|
5
|
-
import type { ComponentAttrs } from '../types'
|
|
1
|
+
<script>
|
|
6
2
|
|
|
7
|
-
export interface FormFieldSlots {
|
|
8
|
-
label?: (props: { label?: string }) => any
|
|
9
|
-
hint?: (props: { hint?: string }) => any
|
|
10
|
-
description?: (props: { description?: string }) => any
|
|
11
|
-
help?: (props: { help?: string }) => any
|
|
12
|
-
error?: (props: { error?: string | boolean }) => any
|
|
13
|
-
default?: (props: { error?: string | boolean }) => any
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type FormItemVariants = VariantProps<typeof formItem>
|
|
17
|
-
|
|
18
|
-
export interface FormItemProps extends ComponentAttrs<typeof formItem> {
|
|
19
|
-
/**
|
|
20
|
-
* The element or component this component should render as.
|
|
21
|
-
* @default "div"
|
|
22
|
-
*/
|
|
23
|
-
as?: PrimitiveProps['as']
|
|
24
|
-
/** The name of the FormItem. Also used to match form errors. */
|
|
25
|
-
name?: string
|
|
26
|
-
/** A regular expression to match form error names. */
|
|
27
|
-
errorPattern?: RegExp
|
|
28
|
-
label?: string
|
|
29
|
-
description?: string
|
|
30
|
-
help?: string
|
|
31
|
-
error?: string | boolean
|
|
32
|
-
hint?: string
|
|
33
|
-
/**
|
|
34
|
-
* @default 'md'
|
|
35
|
-
*/
|
|
36
|
-
size?: FormItemVariants['size']
|
|
37
|
-
required?: boolean
|
|
38
|
-
/** If true, validation on input will be active immediately instead of waiting for a blur event. */
|
|
39
|
-
eagerValidation?: boolean
|
|
40
|
-
/**
|
|
41
|
-
* Delay in milliseconds before validating the form on input events.
|
|
42
|
-
* @default 300
|
|
43
|
-
*/
|
|
44
|
-
validateOnInputDelay?: number
|
|
45
|
-
}
|
|
46
3
|
</script>
|
|
47
4
|
|
|
48
|
-
<script setup
|
|
49
|
-
import { Label, Primitive } from
|
|
50
|
-
import { computed, ref, useId } from
|
|
51
|
-
import { injectFormErrors, provideFormInputId, provideFormItem } from
|
|
52
|
-
import { useTheme } from
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { Label, Primitive } from "reka-ui";
|
|
7
|
+
import { computed, ref, useId } from "vue";
|
|
8
|
+
import { injectFormErrors, provideFormInputId, provideFormItem } from "../app/injections";
|
|
9
|
+
import { useTheme } from "../composables/useTheme";
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
as: { type: null, required: false },
|
|
12
|
+
name: { type: String, required: false },
|
|
13
|
+
errorPattern: { type: null, required: false },
|
|
14
|
+
label: { type: String, required: false },
|
|
15
|
+
description: { type: String, required: false },
|
|
16
|
+
help: { type: String, required: false },
|
|
17
|
+
error: { type: [String, Boolean], required: false },
|
|
18
|
+
hint: { type: String, required: false },
|
|
19
|
+
size: { type: null, required: false },
|
|
20
|
+
required: { type: Boolean, required: false },
|
|
21
|
+
eagerValidation: { type: Boolean, required: false },
|
|
22
|
+
validateOnInputDelay: { type: Number, required: false },
|
|
23
|
+
class: { type: null, required: false },
|
|
24
|
+
ui: { type: null, required: false }
|
|
25
|
+
});
|
|
26
|
+
const slots = defineSlots();
|
|
27
|
+
const id = ref(useId());
|
|
28
|
+
const ariaId = id.value;
|
|
29
|
+
provideFormInputId(id);
|
|
30
|
+
const formErrors = injectFormErrors();
|
|
64
31
|
const error = computed(() => {
|
|
65
32
|
if (props.error)
|
|
66
|
-
return props.error
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
return formError?.message
|
|
79
|
-
})
|
|
80
|
-
|
|
33
|
+
return props.error;
|
|
34
|
+
const formError = formErrors?.value.find((error2) => {
|
|
35
|
+
if (error2.name && error2.name === props.name)
|
|
36
|
+
return true;
|
|
37
|
+
if (error2.name && props.errorPattern)
|
|
38
|
+
return error2.name.match(props.errorPattern);
|
|
39
|
+
return false;
|
|
40
|
+
});
|
|
41
|
+
return formError?.message;
|
|
42
|
+
});
|
|
81
43
|
provideFormItem(computed(() => ({
|
|
82
44
|
...props,
|
|
83
45
|
error: error.value,
|
|
84
|
-
ariaId
|
|
85
|
-
})))
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
const style = computed(() => generateStyle('formItem', props))
|
|
46
|
+
ariaId
|
|
47
|
+
})));
|
|
48
|
+
const { generateStyle } = useTheme();
|
|
49
|
+
const style = computed(() => generateStyle("formItem", props));
|
|
89
50
|
</script>
|
|
90
51
|
|
|
91
52
|
<template>
|
|
92
|
-
<Primitive :as="props.as" :class="style.root({ class: [props.class, props.ui?.root] })">
|
|
93
|
-
<div :class="style.wrapper({ class: props.ui?.wrapper })">
|
|
94
|
-
<div v-if="props.label || slots.label" :class="style.labelWrapper({ class: props.ui?.labelWrapper })">
|
|
95
|
-
<Label :for="id" :class="style.label({ class: props.ui?.label })">
|
|
53
|
+
<Primitive :as="props.as" :class="style.root({ class: [props.class, props.ui?.root] })" data-part="root">
|
|
54
|
+
<div :class="style.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
|
|
55
|
+
<div v-if="props.label || slots.label" :class="style.labelWrapper({ class: props.ui?.labelWrapper })" data-part="label-wrapper">
|
|
56
|
+
<Label :for="id" :class="style.label({ class: props.ui?.label })" data-part="label">
|
|
96
57
|
<slot name="label" :label="props.label">
|
|
97
58
|
{{ props.label }}
|
|
98
59
|
</slot>
|
|
99
60
|
</Label>
|
|
100
|
-
<span v-if="props.hint || slots.hint" :id="`${ariaId}-hint`" :class="style.hint({ class: props.ui?.hint })">
|
|
61
|
+
<span v-if="props.hint || slots.hint" :id="`${ariaId}-hint`" :class="style.hint({ class: props.ui?.hint })" data-part="hint">
|
|
101
62
|
<slot name="hint" :hint="props.hint">
|
|
102
63
|
{{ props.hint }}
|
|
103
64
|
</slot>
|
|
104
65
|
</span>
|
|
105
66
|
</div>
|
|
106
67
|
|
|
107
|
-
<p v-if="props.description || slots.description" :id="`${ariaId}-description`" :class="style.description({ class: props.ui?.description })">
|
|
68
|
+
<p v-if="props.description || slots.description" :id="`${ariaId}-description`" :class="style.description({ class: props.ui?.description })" data-part="description">
|
|
108
69
|
<slot name="description" :description="props.description">
|
|
109
70
|
{{ props.description }}
|
|
110
71
|
</slot>
|
|
111
72
|
</p>
|
|
112
73
|
</div>
|
|
113
74
|
|
|
114
|
-
<div :class="(props.label || slots.label || props.description || slots.description) && style.container({ class: props.ui?.container })">
|
|
75
|
+
<div :class="(props.label || slots.label || props.description || slots.description) && style.container({ class: props.ui?.container })" data-part="container">
|
|
115
76
|
<slot :error="error"></slot>
|
|
116
77
|
|
|
117
|
-
<p v-if="
|
|
78
|
+
<p v-if="typeof error === 'string' && error || slots.error" :id="`${ariaId}-error`" :class="style.error({ class: props.ui?.error })" data-part="error">
|
|
118
79
|
<slot name="error" :error="error">
|
|
119
80
|
{{ error }}
|
|
120
81
|
</slot>
|
|
121
82
|
</p>
|
|
122
|
-
<p v-else :class="style.help({ class: props.ui?.help })">
|
|
83
|
+
<p v-else :class="style.help({ class: props.ui?.help })" data-part="help">
|
|
123
84
|
<slot name="help" :help="props.help">
|
|
124
85
|
{{ help }}
|
|
125
86
|
</slot>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { VariantProps } from '@byyuurin/ui-kit';
|
|
2
|
+
import type { PrimitiveProps } from 'reka-ui';
|
|
3
|
+
import type { formItem } from '../theme/index.js';
|
|
4
|
+
import type { ComponentAttrs } from '../types/index.js';
|
|
5
|
+
export interface FormFieldSlots {
|
|
6
|
+
label?: (props: {
|
|
7
|
+
label?: string;
|
|
8
|
+
}) => any;
|
|
9
|
+
hint?: (props: {
|
|
10
|
+
hint?: string;
|
|
11
|
+
}) => any;
|
|
12
|
+
description?: (props: {
|
|
13
|
+
description?: string;
|
|
14
|
+
}) => any;
|
|
15
|
+
help?: (props: {
|
|
16
|
+
help?: string;
|
|
17
|
+
}) => any;
|
|
18
|
+
error?: (props: {
|
|
19
|
+
error?: string | boolean;
|
|
20
|
+
}) => any;
|
|
21
|
+
default?: (props: {
|
|
22
|
+
error?: string | boolean;
|
|
23
|
+
}) => any;
|
|
24
|
+
}
|
|
25
|
+
type FormItemVariants = VariantProps<typeof formItem>;
|
|
26
|
+
export interface FormItemProps extends ComponentAttrs<typeof formItem> {
|
|
27
|
+
/**
|
|
28
|
+
* The element or component this component should render as.
|
|
29
|
+
* @default "div"
|
|
30
|
+
*/
|
|
31
|
+
as?: PrimitiveProps['as'];
|
|
32
|
+
/** The name of the FormItem. Also used to match form errors. */
|
|
33
|
+
name?: string;
|
|
34
|
+
/** A regular expression to match form error names. */
|
|
35
|
+
errorPattern?: RegExp;
|
|
36
|
+
label?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
help?: string;
|
|
39
|
+
error?: string | boolean;
|
|
40
|
+
hint?: string;
|
|
41
|
+
/**
|
|
42
|
+
* @default 'md'
|
|
43
|
+
*/
|
|
44
|
+
size?: FormItemVariants['size'];
|
|
45
|
+
required?: boolean;
|
|
46
|
+
/** If true, validation on input will be active immediately instead of waiting for a blur event. */
|
|
47
|
+
eagerValidation?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Delay in milliseconds before validating the form on input events.
|
|
50
|
+
* @default 300
|
|
51
|
+
*/
|
|
52
|
+
validateOnInputDelay?: number;
|
|
53
|
+
}
|
|
54
|
+
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<FormItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, FormFieldSlots>;
|
|
55
|
+
export default _default;
|
|
56
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
57
|
+
new (): {
|
|
58
|
+
$slots: S;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -1,74 +1,47 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
-
import type { PrimitiveProps } from 'reka-ui'
|
|
4
|
-
import type { InputHTMLAttributes } from 'vue'
|
|
5
|
-
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
|
|
6
|
-
import type { input } from '../theme'
|
|
7
|
-
import type { ComponentAttrs } from '../types'
|
|
1
|
+
<script>
|
|
8
2
|
|
|
9
|
-
export interface InputEmits {
|
|
10
|
-
'update:modelValue': [payload: string | number]
|
|
11
|
-
'blur': [event: FocusEvent]
|
|
12
|
-
'change': [event: Event]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface InputSlots {
|
|
16
|
-
leading?: (props?: {}) => any
|
|
17
|
-
default?: (props?: {}) => any
|
|
18
|
-
trailing?: (props?: {}) => any
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type InputVariants = VariantProps<typeof input>
|
|
22
|
-
|
|
23
|
-
export interface InputProps extends ComponentAttrs<typeof input>, UseComponentIconsProps {
|
|
24
|
-
/**
|
|
25
|
-
* The element or component this component should render as.
|
|
26
|
-
* @default "div"
|
|
27
|
-
*/
|
|
28
|
-
as?: PrimitiveProps['as']
|
|
29
|
-
id?: string
|
|
30
|
-
name?: string
|
|
31
|
-
type?: InputHTMLAttributes['type']
|
|
32
|
-
placeholder?: string
|
|
33
|
-
size?: InputVariants['size']
|
|
34
|
-
variant?: InputVariants['variant']
|
|
35
|
-
loading?: boolean
|
|
36
|
-
highlight?: boolean
|
|
37
|
-
underline?: boolean
|
|
38
|
-
required?: boolean
|
|
39
|
-
autocomplete?: InputHTMLAttributes['autocomplete']
|
|
40
|
-
autofocus?: boolean
|
|
41
|
-
autofocusDelay?: number
|
|
42
|
-
disabled?: boolean
|
|
43
|
-
}
|
|
44
3
|
</script>
|
|
45
4
|
|
|
46
|
-
<script setup
|
|
47
|
-
import { Primitive } from
|
|
48
|
-
import { computed, onMounted, ref } from
|
|
49
|
-
import { useButtonGroup } from
|
|
50
|
-
import { useComponentIcons } from
|
|
51
|
-
import { useFormItem } from
|
|
52
|
-
import { useTheme } from
|
|
53
|
-
import { looseToNumber } from
|
|
54
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { Primitive } from "reka-ui";
|
|
7
|
+
import { computed, onMounted, ref } from "vue";
|
|
8
|
+
import { useButtonGroup } from "../composables/useButtonGroup";
|
|
9
|
+
import { useComponentIcons } from "../composables/useComponentIcons";
|
|
10
|
+
import { useFormItem } from "../composables/useFormItem";
|
|
11
|
+
import { useTheme } from "../composables/useTheme";
|
|
12
|
+
import { looseToNumber } from "../utils";
|
|
55
13
|
defineOptions({
|
|
56
|
-
inheritAttrs: false
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
type:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
14
|
+
inheritAttrs: false
|
|
15
|
+
});
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
as: { type: null, required: false },
|
|
18
|
+
id: { type: String, required: false },
|
|
19
|
+
name: { type: String, required: false },
|
|
20
|
+
type: { type: null, required: false, default: "text" },
|
|
21
|
+
placeholder: { type: String, required: false },
|
|
22
|
+
size: { type: null, required: false },
|
|
23
|
+
variant: { type: null, required: false, default: "outline" },
|
|
24
|
+
loading: { type: Boolean, required: false },
|
|
25
|
+
highlight: { type: Boolean, required: false },
|
|
26
|
+
underline: { type: Boolean, required: false },
|
|
27
|
+
required: { type: Boolean, required: false },
|
|
28
|
+
autocomplete: { type: null, required: false, default: "off" },
|
|
29
|
+
autofocus: { type: Boolean, required: false },
|
|
30
|
+
autofocusDelay: { type: Number, required: false, default: 0 },
|
|
31
|
+
disabled: { type: Boolean, required: false },
|
|
32
|
+
class: { type: null, required: false },
|
|
33
|
+
ui: { type: null, required: false },
|
|
34
|
+
icon: { type: String, 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
|
+
loadingIcon: { type: String, required: false }
|
|
40
|
+
});
|
|
41
|
+
const emit = defineEmits(["update:modelValue", "blur", "change"]);
|
|
42
|
+
const slots = defineSlots();
|
|
43
|
+
const [modelValue, modelModifiers] = defineModel({ type: [String, Number] });
|
|
44
|
+
const inputRef = ref(null);
|
|
72
45
|
const {
|
|
73
46
|
size: formItemSize,
|
|
74
47
|
id,
|
|
@@ -79,83 +52,72 @@ const {
|
|
|
79
52
|
emitFormBlur,
|
|
80
53
|
emitFormInput,
|
|
81
54
|
emitFormChange,
|
|
82
|
-
emitFormFocus
|
|
83
|
-
} = useFormItem
|
|
84
|
-
const { size: buttonGroupSize, orientation } = useButtonGroup(props)
|
|
85
|
-
const { isLeading, leadingIconName, isTrailing, trailingIconName } = useComponentIcons(props)
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
const style = computed(() => generateStyle('input', {
|
|
55
|
+
emitFormFocus
|
|
56
|
+
} = useFormItem(props, { deferInputValidation: true });
|
|
57
|
+
const { size: buttonGroupSize, orientation } = useButtonGroup(props);
|
|
58
|
+
const { isLeading, leadingIconName, isTrailing, trailingIconName } = useComponentIcons(props);
|
|
59
|
+
const { generateStyle } = useTheme();
|
|
60
|
+
const style = computed(() => generateStyle("input", {
|
|
89
61
|
...props,
|
|
90
|
-
type: props.type
|
|
62
|
+
type: props.type,
|
|
91
63
|
size: buttonGroupSize.value || formItemSize.value,
|
|
92
64
|
highlight: highlight.value,
|
|
93
65
|
groupOrientation: orientation.value,
|
|
94
66
|
leading: isLeading.value || !!slots.leading,
|
|
95
|
-
trailing: isTrailing.value || !!slots.trailing
|
|
96
|
-
}))
|
|
97
|
-
|
|
67
|
+
trailing: isTrailing.value || !!slots.trailing
|
|
68
|
+
}));
|
|
98
69
|
function autoFocus() {
|
|
99
70
|
if (props.autofocus)
|
|
100
|
-
inputRef.value?.focus()
|
|
71
|
+
inputRef.value?.focus();
|
|
101
72
|
}
|
|
102
|
-
|
|
103
|
-
function updateInput(value: string) {
|
|
73
|
+
function updateInput(value) {
|
|
104
74
|
if (modelModifiers.trim)
|
|
105
|
-
value = value.trim()
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
modelValue.value = value
|
|
111
|
-
emitFormInput()
|
|
75
|
+
value = value.trim();
|
|
76
|
+
if (modelModifiers.number || props.type === "number")
|
|
77
|
+
value = looseToNumber(value);
|
|
78
|
+
modelValue.value = value;
|
|
79
|
+
emitFormInput();
|
|
112
80
|
}
|
|
113
|
-
|
|
114
|
-
function onInput(event: Event) {
|
|
81
|
+
function onInput(event) {
|
|
115
82
|
if (!modelModifiers.lazy)
|
|
116
|
-
updateInput(
|
|
83
|
+
updateInput(event.target.value);
|
|
117
84
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const value = (event.target as HTMLInputElement).value
|
|
121
|
-
|
|
85
|
+
function onChange(event) {
|
|
86
|
+
const value = event.target.value;
|
|
122
87
|
if (modelModifiers.lazy)
|
|
123
|
-
updateInput(value)
|
|
124
|
-
|
|
88
|
+
updateInput(value);
|
|
125
89
|
if (modelModifiers.trim)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
emitFormChange()
|
|
90
|
+
event.target.value = value.trim();
|
|
91
|
+
emit("change", event);
|
|
92
|
+
emitFormChange();
|
|
130
93
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
emitFormBlur()
|
|
94
|
+
function onBlur(event) {
|
|
95
|
+
emit("blur", event);
|
|
96
|
+
emitFormBlur();
|
|
135
97
|
}
|
|
136
|
-
|
|
137
98
|
defineExpose({
|
|
138
|
-
inputRef
|
|
139
|
-
})
|
|
140
|
-
|
|
99
|
+
inputRef
|
|
100
|
+
});
|
|
141
101
|
onMounted(() => {
|
|
142
102
|
setTimeout(() => {
|
|
143
|
-
autoFocus()
|
|
144
|
-
}, props.autofocusDelay)
|
|
145
|
-
})
|
|
103
|
+
autoFocus();
|
|
104
|
+
}, props.autofocusDelay);
|
|
105
|
+
});
|
|
146
106
|
</script>
|
|
147
107
|
|
|
148
108
|
<template>
|
|
149
109
|
<Primitive
|
|
150
110
|
:as="as"
|
|
111
|
+
:aria-disabled="disabled ? true : void 0"
|
|
151
112
|
:class="style.base({ class: [props.class, props.ui?.base] })"
|
|
152
|
-
:
|
|
113
|
+
:data-part="$attrs['data-part'] ?? 'base'"
|
|
153
114
|
>
|
|
154
|
-
<span v-if="isLeading || slots.leading" :class="style.leading({ class: props.ui?.leading })">
|
|
115
|
+
<span v-if="isLeading || slots.leading" :class="style.leading({ class: props.ui?.leading })" data-part="leading">
|
|
155
116
|
<slot name="leading">
|
|
156
117
|
<span
|
|
157
118
|
v-if="isLeading && leadingIconName"
|
|
158
119
|
:class="style.leadingIcon({ class: [leadingIconName, props.ui?.leadingIcon] })"
|
|
120
|
+
data-part="leading-icon"
|
|
159
121
|
></span>
|
|
160
122
|
</slot>
|
|
161
123
|
</span>
|
|
@@ -163,6 +125,7 @@ onMounted(() => {
|
|
|
163
125
|
<input
|
|
164
126
|
ref="inputRef"
|
|
165
127
|
:class="style.input({ class: props.ui?.input })"
|
|
128
|
+
data-part="input"
|
|
166
129
|
:type="props.type"
|
|
167
130
|
:value="modelValue"
|
|
168
131
|
:placeholder="props.placeholder"
|
|
@@ -177,11 +140,12 @@ onMounted(() => {
|
|
|
177
140
|
|
|
178
141
|
<slot></slot>
|
|
179
142
|
|
|
180
|
-
<span v-if="isTrailing || slots.trailing" :class="style.trailing({ class: props.ui?.trailing })">
|
|
143
|
+
<span v-if="isTrailing || slots.trailing" :class="style.trailing({ class: props.ui?.trailing })" data-part="trailing">
|
|
181
144
|
<slot name="trailing">
|
|
182
145
|
<span
|
|
183
146
|
v-if="isTrailing && trailingIconName"
|
|
184
147
|
:class="style.trailingIcon({ class: [trailingIconName, props.ui?.trailingIcon] })"
|
|
148
|
+
data-part="trailing-icon"
|
|
185
149
|
></span>
|
|
186
150
|
</slot>
|
|
187
151
|
</span>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { VariantProps } from '@byyuurin/ui-kit';
|
|
2
|
+
import type { PrimitiveProps } from 'reka-ui';
|
|
3
|
+
import type { InputHTMLAttributes } from 'vue';
|
|
4
|
+
import type { UseComponentIconsProps } from '../composables/useComponentIcons.js';
|
|
5
|
+
import type { input } from '../theme/index.js';
|
|
6
|
+
import type { ComponentAttrs } from '../types/index.js';
|
|
7
|
+
export interface InputEmits {
|
|
8
|
+
'update:modelValue': [payload: string | number];
|
|
9
|
+
'blur': [event: FocusEvent];
|
|
10
|
+
'change': [event: Event];
|
|
11
|
+
}
|
|
12
|
+
export interface InputSlots {
|
|
13
|
+
leading?: (props?: {}) => any;
|
|
14
|
+
default?: (props?: {}) => any;
|
|
15
|
+
trailing?: (props?: {}) => any;
|
|
16
|
+
}
|
|
17
|
+
type InputVariants = VariantProps<typeof input>;
|
|
18
|
+
export interface InputProps extends ComponentAttrs<typeof input>, UseComponentIconsProps {
|
|
19
|
+
/**
|
|
20
|
+
* The element or component this component should render as.
|
|
21
|
+
* @default "div"
|
|
22
|
+
*/
|
|
23
|
+
as?: PrimitiveProps['as'];
|
|
24
|
+
id?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
type?: InputHTMLAttributes['type'];
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
size?: InputVariants['size'];
|
|
29
|
+
variant?: InputVariants['variant'];
|
|
30
|
+
loading?: boolean;
|
|
31
|
+
highlight?: boolean;
|
|
32
|
+
underline?: boolean;
|
|
33
|
+
required?: boolean;
|
|
34
|
+
autocomplete?: InputHTMLAttributes['autocomplete'];
|
|
35
|
+
autofocus?: boolean;
|
|
36
|
+
autofocusDelay?: number;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
}
|
|
39
|
+
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<InputProps & {
|
|
40
|
+
modelValue?: string | number;
|
|
41
|
+
}, {
|
|
42
|
+
inputRef: import("vue").Ref<HTMLInputElement | null, HTMLInputElement | null>;
|
|
43
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
44
|
+
blur: (event: FocusEvent) => any;
|
|
45
|
+
change: (event: Event) => any;
|
|
46
|
+
"update:modelValue": (...args: unknown[]) => any;
|
|
47
|
+
}, string, import("vue").PublicProps, Readonly<InputProps & {
|
|
48
|
+
modelValue?: string | number;
|
|
49
|
+
}> & Readonly<{
|
|
50
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
51
|
+
onChange?: ((event: Event) => any) | undefined;
|
|
52
|
+
"onUpdate:modelValue"?: ((...args: unknown[]) => any) | undefined;
|
|
53
|
+
}>, {
|
|
54
|
+
variant: "outline" | "soft" | "soft-outline" | "ghost" | "none";
|
|
55
|
+
type: import("vue").InputTypeHTMLAttribute;
|
|
56
|
+
autocomplete: string;
|
|
57
|
+
autofocusDelay: number;
|
|
58
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, InputSlots>;
|
|
59
|
+
export default _default;
|
|
60
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
61
|
+
new (): {
|
|
62
|
+
$slots: S;
|
|
63
|
+
};
|
|
64
|
+
};
|