@bobbykim/mcl-forms 0.2.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/CHANGELOG.md +21 -0
- package/LICENSE.md +9 -0
- package/README.md +21 -0
- package/index.d.ts +10 -0
- package/index.js +10 -0
- package/index.ts +19 -0
- package/lib/assets/CaretDown.vue +14 -0
- package/lib/assets/CaretDown.vue.d.ts +2 -0
- package/lib/common/InputHighlight.vue +46 -0
- package/lib/common/InputHighlight.vue.d.ts +41 -0
- package/lib/common/index.types.d.ts +4 -0
- package/lib/common/index.types.js +1 -0
- package/lib/common/index.types.ts +5 -0
- package/lib/mcl-form-group/MclFormGroup.vue +48 -0
- package/lib/mcl-form-group/MclFormGroup.vue.d.ts +52 -0
- package/lib/mcl-input-file/MclInputFile.vue +151 -0
- package/lib/mcl-input-file/MclInputFile.vue.d.ts +93 -0
- package/lib/mcl-input-radio/MclInputRadio.vue +92 -0
- package/lib/mcl-input-radio/MclInputRadio.vue.d.ts +62 -0
- package/lib/mcl-input-radio/index.types.d.ts +5 -0
- package/lib/mcl-input-radio/index.types.js +1 -0
- package/lib/mcl-input-radio/index.types.ts +6 -0
- package/lib/mcl-input-switch/MclInputSwitch.vue +147 -0
- package/lib/mcl-input-switch/MclInputSwitch.vue.d.ts +59 -0
- package/lib/mcl-input-switch/index.types.d.ts +1 -0
- package/lib/mcl-input-switch/index.types.js +1 -0
- package/lib/mcl-input-switch/index.types.ts +1 -0
- package/lib/mcl-input-text/MclInputText.vue +113 -0
- package/lib/mcl-input-text/MclInputText.vue.d.ts +103 -0
- package/lib/mcl-select/MclSelect.vue +287 -0
- package/lib/mcl-select/MclSelect.vue.d.ts +108 -0
- package/lib/mcl-select/index.types.d.ts +5 -0
- package/lib/mcl-select/index.types.js +1 -0
- package/lib/mcl-select/index.types.ts +6 -0
- package/lib/mcl-text-area/MclTextArea.vue +100 -0
- package/lib/mcl-text-area/MclTextArea.vue.d.ts +88 -0
- package/package.json +1 -0
- package/tsconfig.json +9 -0
- package/tsconfig.vue.json +9 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ColorPalette } from '@bobbykim/manguito-theme'
|
|
3
|
+
import generateClass, { vClickOutside } from '@bobbykim/manguito-theme'
|
|
4
|
+
import { useResizeObserver } from '@vueuse/core'
|
|
5
|
+
import { Transition, computed, ref } from 'vue'
|
|
6
|
+
import type { SelectOptionType, SelectOptions } from './index.types'
|
|
7
|
+
|
|
8
|
+
const props = withDefaults(
|
|
9
|
+
defineProps<{
|
|
10
|
+
id: string
|
|
11
|
+
displayBorder?: boolean
|
|
12
|
+
borderColor?: ColorPalette
|
|
13
|
+
rounded?: boolean
|
|
14
|
+
displayHighlight?: boolean
|
|
15
|
+
highlightColor?: ColorPalette
|
|
16
|
+
textcolor?: ColorPalette
|
|
17
|
+
bgColor?: ColorPalette
|
|
18
|
+
iconColor?: ColorPalette
|
|
19
|
+
placeholder?: string
|
|
20
|
+
displayShadow?: boolean
|
|
21
|
+
required?: boolean
|
|
22
|
+
options: SelectOptions
|
|
23
|
+
selectColor?: ColorPalette
|
|
24
|
+
invalidFeedback?: string
|
|
25
|
+
modelValue?: string
|
|
26
|
+
}>(),
|
|
27
|
+
{
|
|
28
|
+
displayBorder: false,
|
|
29
|
+
borderColor: 'light-4',
|
|
30
|
+
rounded: false,
|
|
31
|
+
displayHighlight: true,
|
|
32
|
+
highlightColor: 'primary',
|
|
33
|
+
textcolor: 'black',
|
|
34
|
+
bgColor: 'light-1',
|
|
35
|
+
iconColor: 'dark-4',
|
|
36
|
+
selectColor: 'primary',
|
|
37
|
+
placeholder: '',
|
|
38
|
+
displayShadow: true,
|
|
39
|
+
required: false,
|
|
40
|
+
invalidFeedback: 'No match.',
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const emit = defineEmits(['update:modelValue'])
|
|
45
|
+
const componentRef = ref<HTMLElement>()
|
|
46
|
+
const inputBox = ref<HTMLInputElement>()
|
|
47
|
+
const optionsWidth = ref<number>()
|
|
48
|
+
const inputFocus = ref<boolean>(false)
|
|
49
|
+
const selectedValue = ref<string | SelectOptionType>('')
|
|
50
|
+
|
|
51
|
+
const setInputFocus = () => {
|
|
52
|
+
inputFocus.value = true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const handleEscapeKeyUp = () => {
|
|
56
|
+
selectedValue.value = ''
|
|
57
|
+
inputFocus.value = false
|
|
58
|
+
inputBox.value?.blur()
|
|
59
|
+
emit('update:modelValue', '')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const handleClickOutside = () => {
|
|
63
|
+
inputFocus.value = false
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const handleToggle = () => {
|
|
67
|
+
inputFocus.value = !inputFocus.value
|
|
68
|
+
if (inputFocus.value === true) {
|
|
69
|
+
inputBox.value?.focus()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const clearInput = (e: Event) => {
|
|
74
|
+
e.preventDefault()
|
|
75
|
+
if (selectedValue.value !== '') {
|
|
76
|
+
selectedValue.value = ''
|
|
77
|
+
}
|
|
78
|
+
emit('update:modelValue', '')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const handleOptionClick = (e: Event, option: string | SelectOptionType) => {
|
|
82
|
+
e.preventDefault()
|
|
83
|
+
selectedValue.value = typeof option === 'string' ? option : option.text
|
|
84
|
+
const outputVal = typeof option === 'string' ? option : option.value
|
|
85
|
+
emit('update:modelValue', outputVal)
|
|
86
|
+
inputFocus.value = false
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const containerClass = computed(() => {
|
|
90
|
+
const {
|
|
91
|
+
bgColor,
|
|
92
|
+
displayBorder,
|
|
93
|
+
borderColor,
|
|
94
|
+
displayHighlight,
|
|
95
|
+
displayShadow,
|
|
96
|
+
rounded,
|
|
97
|
+
textcolor,
|
|
98
|
+
} = props
|
|
99
|
+
const classArray: string[] = [
|
|
100
|
+
generateClass('BGCOLOR', bgColor),
|
|
101
|
+
generateClass('TEXTCOLOR', textcolor),
|
|
102
|
+
]
|
|
103
|
+
if (displayBorder) {
|
|
104
|
+
classArray.push('border-2')
|
|
105
|
+
classArray.push(generateClass('BORDER', borderColor))
|
|
106
|
+
}
|
|
107
|
+
if (!displayHighlight) {
|
|
108
|
+
classArray.push('ring-offset-2 transition-all duration-300 ease-linear')
|
|
109
|
+
}
|
|
110
|
+
if (displayShadow) {
|
|
111
|
+
classArray.push('shadow-md')
|
|
112
|
+
}
|
|
113
|
+
if (rounded) {
|
|
114
|
+
classArray.push('rounded-md')
|
|
115
|
+
}
|
|
116
|
+
return classArray.join(' ')
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
const getHighlightClass = (color: ColorPalette, rounded: boolean): string => {
|
|
120
|
+
/**
|
|
121
|
+
* @color - highlightColor
|
|
122
|
+
* @rounded - rounded
|
|
123
|
+
*/
|
|
124
|
+
const classArray: string[] = [generateClass('BEFOREBG', color)]
|
|
125
|
+
if (rounded) {
|
|
126
|
+
classArray.push('rounded-b-md')
|
|
127
|
+
}
|
|
128
|
+
return classArray.join(' ')
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const optionsBlockClass = computed(() => {
|
|
132
|
+
const { displayHighlight, bgColor, borderColor, rounded } = props
|
|
133
|
+
const classArray: string[] = [
|
|
134
|
+
generateClass('BGCOLOR', bgColor),
|
|
135
|
+
generateClass('BORDER', borderColor),
|
|
136
|
+
]
|
|
137
|
+
if (!displayHighlight) {
|
|
138
|
+
classArray.push('mt-2xs')
|
|
139
|
+
}
|
|
140
|
+
if (rounded) {
|
|
141
|
+
classArray.push('rounded-md')
|
|
142
|
+
}
|
|
143
|
+
return classArray.join(' ')
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const filteredOptions = computed(() => {
|
|
147
|
+
if (selectedValue.value === '') {
|
|
148
|
+
return props.options
|
|
149
|
+
} else {
|
|
150
|
+
const filteredData = props.options.filter((data) => {
|
|
151
|
+
const textVal = new RegExp(`${selectedValue.value}`, 'gi')
|
|
152
|
+
return typeof data === 'string'
|
|
153
|
+
? data.match(textVal)
|
|
154
|
+
: data.text.match(textVal)
|
|
155
|
+
})
|
|
156
|
+
return filteredData
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
const handleOptionsWidth = computed(() => {
|
|
161
|
+
return { width: `${optionsWidth.value}px` }
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
useResizeObserver(componentRef, () => {
|
|
165
|
+
if (componentRef.value) {
|
|
166
|
+
optionsWidth.value = componentRef.value.clientWidth
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
</script>
|
|
170
|
+
|
|
171
|
+
<template>
|
|
172
|
+
<div
|
|
173
|
+
@keyup.esc="handleEscapeKeyUp"
|
|
174
|
+
v-click-outside="handleClickOutside"
|
|
175
|
+
ref="componentRef"
|
|
176
|
+
>
|
|
177
|
+
<div
|
|
178
|
+
class="p-2xs flex relative gap-3xs"
|
|
179
|
+
:class="[
|
|
180
|
+
!displayHighlight &&
|
|
181
|
+
inputFocus &&
|
|
182
|
+
generateClass('RINGCOLOR', borderColor) + ' ring-4',
|
|
183
|
+
containerClass,
|
|
184
|
+
]"
|
|
185
|
+
>
|
|
186
|
+
<input
|
|
187
|
+
:id="id"
|
|
188
|
+
type="text"
|
|
189
|
+
class="w-full bg-transparent outline-none"
|
|
190
|
+
v-model="selectedValue"
|
|
191
|
+
ref="inputBox"
|
|
192
|
+
role="combobox"
|
|
193
|
+
:placeholder="placeholder"
|
|
194
|
+
aria-autocomplete="list"
|
|
195
|
+
:aria-expanded="inputFocus"
|
|
196
|
+
@focus="setInputFocus"
|
|
197
|
+
/>
|
|
198
|
+
<div
|
|
199
|
+
class="flex items-center px-3xs"
|
|
200
|
+
:class="[
|
|
201
|
+
selectedValue === '' ? 'hidden cursor-text' : 'block cursor-pointer',
|
|
202
|
+
]"
|
|
203
|
+
@click="clearInput"
|
|
204
|
+
>
|
|
205
|
+
<svg
|
|
206
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
207
|
+
viewBox="0 0 384 512"
|
|
208
|
+
class="h-xs opacity-70"
|
|
209
|
+
:class="[generateClass('SVGFILL', iconColor)]"
|
|
210
|
+
>
|
|
211
|
+
<!-- !Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc. -->
|
|
212
|
+
<path
|
|
213
|
+
d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"
|
|
214
|
+
/>
|
|
215
|
+
</svg>
|
|
216
|
+
</div>
|
|
217
|
+
<div class="flex items-center px-3xs" @click="handleToggle">
|
|
218
|
+
<svg
|
|
219
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
220
|
+
viewBox="0 0 320 512"
|
|
221
|
+
class="h-xs"
|
|
222
|
+
:class="[
|
|
223
|
+
!inputFocus ? 'rotate-0' : 'rotate-180',
|
|
224
|
+
'transition-transform duration-300 ease-in',
|
|
225
|
+
generateClass('SVGFILL', iconColor),
|
|
226
|
+
]"
|
|
227
|
+
>
|
|
228
|
+
<!-- Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc. -->
|
|
229
|
+
<path
|
|
230
|
+
d="M137.4 374.6c12.5 12.5 32.8 12.5 45.3 0l128-128c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8L32 192c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l128 128z"
|
|
231
|
+
/>
|
|
232
|
+
</svg>
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
<div
|
|
236
|
+
v-if="displayHighlight"
|
|
237
|
+
class="relative h-3xs overflow-hidden before:absolute before:bottom-0 before:left-0 before:h-full before:w-0 before:transition-[width] before:duration-300 before:ease-linear -top-1"
|
|
238
|
+
:class="[
|
|
239
|
+
inputFocus ? 'before:w-full' : 'before:w-0',
|
|
240
|
+
getHighlightClass(highlightColor, rounded),
|
|
241
|
+
]"
|
|
242
|
+
></div>
|
|
243
|
+
<transition name="options">
|
|
244
|
+
<div class="absolute" v-if="inputFocus">
|
|
245
|
+
<ul
|
|
246
|
+
:class="[optionsBlockClass]"
|
|
247
|
+
class="max-h-[200px] overflow-y-auto border-2"
|
|
248
|
+
:style="handleOptionsWidth"
|
|
249
|
+
role="listbox"
|
|
250
|
+
>
|
|
251
|
+
<li
|
|
252
|
+
v-for="(option, idx) in filteredOptions"
|
|
253
|
+
:key="idx"
|
|
254
|
+
class="p-2xs cursor-pointer"
|
|
255
|
+
role="option"
|
|
256
|
+
:class="[generateClass('HVBGCOLOR', highlightColor)]"
|
|
257
|
+
@click="handleOptionClick($event, option)"
|
|
258
|
+
>
|
|
259
|
+
{{ typeof option === 'string' ? option : option.text }}
|
|
260
|
+
</li>
|
|
261
|
+
<li
|
|
262
|
+
v-if="selectedValue !== '' && filteredOptions.length === 0"
|
|
263
|
+
class="p-2xs cursor-pointer"
|
|
264
|
+
:class="[generateClass('HVBGCOLOR', selectColor)]"
|
|
265
|
+
>
|
|
266
|
+
<slot name="no-match">
|
|
267
|
+
<span>{{ invalidFeedback }}</span>
|
|
268
|
+
</slot>
|
|
269
|
+
</li>
|
|
270
|
+
</ul>
|
|
271
|
+
</div>
|
|
272
|
+
</transition>
|
|
273
|
+
</div>
|
|
274
|
+
</template>
|
|
275
|
+
|
|
276
|
+
<style lang="scss" scoped>
|
|
277
|
+
.options-enter-active,
|
|
278
|
+
.options-leave-active {
|
|
279
|
+
opacity: 1;
|
|
280
|
+
transition: all 0.3s;
|
|
281
|
+
}
|
|
282
|
+
.options-enter-from,
|
|
283
|
+
.options-leave-to {
|
|
284
|
+
opacity: 0;
|
|
285
|
+
transform: translateY(-10px);
|
|
286
|
+
}
|
|
287
|
+
</style>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ColorPalette } from '@bobbykim/manguito-theme';
|
|
2
|
+
import type { SelectOptions } from './index.types';
|
|
3
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
+
id: string;
|
|
5
|
+
displayBorder?: boolean | undefined;
|
|
6
|
+
borderColor?: ColorPalette | undefined;
|
|
7
|
+
rounded?: boolean | undefined;
|
|
8
|
+
displayHighlight?: boolean | undefined;
|
|
9
|
+
highlightColor?: ColorPalette | undefined;
|
|
10
|
+
textcolor?: ColorPalette | undefined;
|
|
11
|
+
bgColor?: ColorPalette | undefined;
|
|
12
|
+
iconColor?: ColorPalette | undefined;
|
|
13
|
+
placeholder?: string | undefined;
|
|
14
|
+
displayShadow?: boolean | undefined;
|
|
15
|
+
required?: boolean | undefined;
|
|
16
|
+
options: SelectOptions;
|
|
17
|
+
selectColor?: ColorPalette | undefined;
|
|
18
|
+
invalidFeedback?: string | undefined;
|
|
19
|
+
modelValue?: string | undefined;
|
|
20
|
+
}>, {
|
|
21
|
+
displayBorder: boolean;
|
|
22
|
+
borderColor: string;
|
|
23
|
+
rounded: boolean;
|
|
24
|
+
displayHighlight: boolean;
|
|
25
|
+
highlightColor: string;
|
|
26
|
+
textcolor: string;
|
|
27
|
+
bgColor: string;
|
|
28
|
+
iconColor: string;
|
|
29
|
+
selectColor: string;
|
|
30
|
+
placeholder: string;
|
|
31
|
+
displayShadow: boolean;
|
|
32
|
+
required: boolean;
|
|
33
|
+
invalidFeedback: string;
|
|
34
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
35
|
+
"update:modelValue": (...args: any[]) => void;
|
|
36
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
37
|
+
id: string;
|
|
38
|
+
displayBorder?: boolean | undefined;
|
|
39
|
+
borderColor?: ColorPalette | undefined;
|
|
40
|
+
rounded?: boolean | undefined;
|
|
41
|
+
displayHighlight?: boolean | undefined;
|
|
42
|
+
highlightColor?: ColorPalette | undefined;
|
|
43
|
+
textcolor?: ColorPalette | undefined;
|
|
44
|
+
bgColor?: ColorPalette | undefined;
|
|
45
|
+
iconColor?: ColorPalette | undefined;
|
|
46
|
+
placeholder?: string | undefined;
|
|
47
|
+
displayShadow?: boolean | undefined;
|
|
48
|
+
required?: boolean | undefined;
|
|
49
|
+
options: SelectOptions;
|
|
50
|
+
selectColor?: ColorPalette | undefined;
|
|
51
|
+
invalidFeedback?: string | undefined;
|
|
52
|
+
modelValue?: string | undefined;
|
|
53
|
+
}>, {
|
|
54
|
+
displayBorder: boolean;
|
|
55
|
+
borderColor: string;
|
|
56
|
+
rounded: boolean;
|
|
57
|
+
displayHighlight: boolean;
|
|
58
|
+
highlightColor: string;
|
|
59
|
+
textcolor: string;
|
|
60
|
+
bgColor: string;
|
|
61
|
+
iconColor: string;
|
|
62
|
+
selectColor: string;
|
|
63
|
+
placeholder: string;
|
|
64
|
+
displayShadow: boolean;
|
|
65
|
+
required: boolean;
|
|
66
|
+
invalidFeedback: string;
|
|
67
|
+
}>>> & {
|
|
68
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
required: boolean;
|
|
71
|
+
placeholder: string;
|
|
72
|
+
rounded: boolean;
|
|
73
|
+
displayBorder: boolean;
|
|
74
|
+
borderColor: ColorPalette;
|
|
75
|
+
bgColor: ColorPalette;
|
|
76
|
+
displayShadow: boolean;
|
|
77
|
+
displayHighlight: boolean;
|
|
78
|
+
highlightColor: ColorPalette;
|
|
79
|
+
textcolor: ColorPalette;
|
|
80
|
+
invalidFeedback: string;
|
|
81
|
+
iconColor: ColorPalette;
|
|
82
|
+
selectColor: ColorPalette;
|
|
83
|
+
}, {}>, {
|
|
84
|
+
"no-match"?(_: {}): any;
|
|
85
|
+
}>;
|
|
86
|
+
export default _default;
|
|
87
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
88
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
89
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
90
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
91
|
+
} : {
|
|
92
|
+
type: import('vue').PropType<T[K]>;
|
|
93
|
+
required: true;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
type __VLS_WithDefaults<P, D> = {
|
|
97
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
98
|
+
default: D[K];
|
|
99
|
+
}> : P[K];
|
|
100
|
+
};
|
|
101
|
+
type __VLS_Prettify<T> = {
|
|
102
|
+
[K in keyof T]: T[K];
|
|
103
|
+
} & {};
|
|
104
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
105
|
+
new (): {
|
|
106
|
+
$slots: S;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import type { ColorPalette } from '@bobbykim/manguito-theme'
|
|
4
|
+
import generateClass from '@bobbykim/manguito-theme'
|
|
5
|
+
import InputHighlight from '../common/InputHighlight.vue'
|
|
6
|
+
|
|
7
|
+
const props = withDefaults(
|
|
8
|
+
defineProps<{
|
|
9
|
+
id: string
|
|
10
|
+
displayBorder?: boolean
|
|
11
|
+
borderColor?: ColorPalette
|
|
12
|
+
rounded?: boolean
|
|
13
|
+
displayHighlight?: boolean
|
|
14
|
+
highlightColor?: ColorPalette
|
|
15
|
+
bgColor?: ColorPalette
|
|
16
|
+
textcolor?: ColorPalette
|
|
17
|
+
placeholder?: string
|
|
18
|
+
displayShadow?: boolean
|
|
19
|
+
required?: boolean
|
|
20
|
+
rows?: number
|
|
21
|
+
modelValue?: string
|
|
22
|
+
}>(),
|
|
23
|
+
{
|
|
24
|
+
displayBorder: false,
|
|
25
|
+
borderColor: 'light-4',
|
|
26
|
+
rounded: false,
|
|
27
|
+
displayHighlight: true,
|
|
28
|
+
highlightColor: 'primary',
|
|
29
|
+
bgColor: 'light-1',
|
|
30
|
+
textcolor: 'black',
|
|
31
|
+
placeholder: '',
|
|
32
|
+
displayShadow: true,
|
|
33
|
+
required: false,
|
|
34
|
+
rows: 5,
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
const emit = defineEmits(['update:modelValue'])
|
|
39
|
+
const inputValue = computed({
|
|
40
|
+
get() {
|
|
41
|
+
return props.modelValue
|
|
42
|
+
},
|
|
43
|
+
set(value) {
|
|
44
|
+
emit('update:modelValue', value)
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const inputClass = computed(() => {
|
|
49
|
+
const {
|
|
50
|
+
bgColor,
|
|
51
|
+
displayBorder,
|
|
52
|
+
borderColor,
|
|
53
|
+
displayHighlight,
|
|
54
|
+
displayShadow,
|
|
55
|
+
rounded,
|
|
56
|
+
textcolor,
|
|
57
|
+
} = props
|
|
58
|
+
const classArray: string[] = [
|
|
59
|
+
generateClass('BGCOLOR', bgColor),
|
|
60
|
+
generateClass('TEXTCOLOR', textcolor),
|
|
61
|
+
]
|
|
62
|
+
if (displayBorder) {
|
|
63
|
+
classArray.push('border-2')
|
|
64
|
+
classArray.push(generateClass('BORDER', borderColor))
|
|
65
|
+
}
|
|
66
|
+
if (!displayHighlight) {
|
|
67
|
+
classArray.push(
|
|
68
|
+
'focus:ring-4 ring-offset-2 transition-all duration-300 ease-linear'
|
|
69
|
+
)
|
|
70
|
+
classArray.push(generateClass('FOCUSRING', borderColor))
|
|
71
|
+
}
|
|
72
|
+
if (displayShadow) {
|
|
73
|
+
classArray.push('shadow-md')
|
|
74
|
+
}
|
|
75
|
+
if (rounded) {
|
|
76
|
+
classArray.push('rounded-md')
|
|
77
|
+
}
|
|
78
|
+
return classArray.join(' ')
|
|
79
|
+
})
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<template>
|
|
83
|
+
<div>
|
|
84
|
+
<textarea
|
|
85
|
+
:id="id"
|
|
86
|
+
class="w-full p-2xs outline-none input__text peer"
|
|
87
|
+
:class="inputClass"
|
|
88
|
+
v-model="inputValue"
|
|
89
|
+
:placeholder="placeholder"
|
|
90
|
+
:required="required"
|
|
91
|
+
:rows="rows"
|
|
92
|
+
/>
|
|
93
|
+
<input-highlight
|
|
94
|
+
v-if="displayHighlight"
|
|
95
|
+
:color="highlightColor"
|
|
96
|
+
:rounded="rounded"
|
|
97
|
+
:offset="2.5"
|
|
98
|
+
></input-highlight>
|
|
99
|
+
</div>
|
|
100
|
+
</template>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ColorPalette } from '@bobbykim/manguito-theme';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
3
|
+
id: string;
|
|
4
|
+
displayBorder?: boolean | undefined;
|
|
5
|
+
borderColor?: ColorPalette | undefined;
|
|
6
|
+
rounded?: boolean | undefined;
|
|
7
|
+
displayHighlight?: boolean | undefined;
|
|
8
|
+
highlightColor?: ColorPalette | undefined;
|
|
9
|
+
bgColor?: ColorPalette | undefined;
|
|
10
|
+
textcolor?: ColorPalette | undefined;
|
|
11
|
+
placeholder?: string | undefined;
|
|
12
|
+
displayShadow?: boolean | undefined;
|
|
13
|
+
required?: boolean | undefined;
|
|
14
|
+
rows?: number | undefined;
|
|
15
|
+
modelValue?: string | undefined;
|
|
16
|
+
}>, {
|
|
17
|
+
displayBorder: boolean;
|
|
18
|
+
borderColor: string;
|
|
19
|
+
rounded: boolean;
|
|
20
|
+
displayHighlight: boolean;
|
|
21
|
+
highlightColor: string;
|
|
22
|
+
bgColor: string;
|
|
23
|
+
textcolor: string;
|
|
24
|
+
placeholder: string;
|
|
25
|
+
displayShadow: boolean;
|
|
26
|
+
required: boolean;
|
|
27
|
+
rows: number;
|
|
28
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
29
|
+
"update:modelValue": (...args: any[]) => void;
|
|
30
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
31
|
+
id: string;
|
|
32
|
+
displayBorder?: boolean | undefined;
|
|
33
|
+
borderColor?: ColorPalette | undefined;
|
|
34
|
+
rounded?: boolean | undefined;
|
|
35
|
+
displayHighlight?: boolean | undefined;
|
|
36
|
+
highlightColor?: ColorPalette | undefined;
|
|
37
|
+
bgColor?: ColorPalette | undefined;
|
|
38
|
+
textcolor?: ColorPalette | undefined;
|
|
39
|
+
placeholder?: string | undefined;
|
|
40
|
+
displayShadow?: boolean | undefined;
|
|
41
|
+
required?: boolean | undefined;
|
|
42
|
+
rows?: number | undefined;
|
|
43
|
+
modelValue?: string | undefined;
|
|
44
|
+
}>, {
|
|
45
|
+
displayBorder: boolean;
|
|
46
|
+
borderColor: string;
|
|
47
|
+
rounded: boolean;
|
|
48
|
+
displayHighlight: boolean;
|
|
49
|
+
highlightColor: string;
|
|
50
|
+
bgColor: string;
|
|
51
|
+
textcolor: string;
|
|
52
|
+
placeholder: string;
|
|
53
|
+
displayShadow: boolean;
|
|
54
|
+
required: boolean;
|
|
55
|
+
rows: number;
|
|
56
|
+
}>>> & {
|
|
57
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
required: boolean;
|
|
60
|
+
placeholder: string;
|
|
61
|
+
rounded: boolean;
|
|
62
|
+
displayBorder: boolean;
|
|
63
|
+
borderColor: ColorPalette;
|
|
64
|
+
bgColor: ColorPalette;
|
|
65
|
+
displayShadow: boolean;
|
|
66
|
+
displayHighlight: boolean;
|
|
67
|
+
highlightColor: ColorPalette;
|
|
68
|
+
textcolor: ColorPalette;
|
|
69
|
+
rows: number;
|
|
70
|
+
}, {}>;
|
|
71
|
+
export default _default;
|
|
72
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
73
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
74
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
75
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
76
|
+
} : {
|
|
77
|
+
type: import('vue').PropType<T[K]>;
|
|
78
|
+
required: true;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
type __VLS_WithDefaults<P, D> = {
|
|
82
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
83
|
+
default: D[K];
|
|
84
|
+
}> : P[K];
|
|
85
|
+
};
|
|
86
|
+
type __VLS_Prettify<T> = {
|
|
87
|
+
[K in keyof T]: T[K];
|
|
88
|
+
} & {};
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@bobbykim/mcl-forms","version":"0.2.0","description":"","type":"module","main":"index.ts","scripts":{"build":"vue-tsc --project tsconfig.vue.json && tsc"},"author":{"name":"Bobby Kim","url":"https://www.devbobbykim.com/"},"homepage":"https://manguito-component-library.vercel.app/","repository":{"type":"git","url":"https://github.com/bobbykim89/manguito-component-library.git"},"publishConfig":{"access":"public"},"license":"MIT","dependencies":{"@bobbykim/manguito-theme":"^0.14.0"},"gitHead":"4d94a8d34988d926c8d465891fd7aa535cffdf33"}
|
package/tsconfig.json
ADDED