@a-vision-software/vue-input-components 1.4.8 → 1.4.10
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 +12 -0
- package/dist/src/components/TextInput.vue.d.ts +2 -2
- package/dist/src/global.d.ts +22 -0
- package/dist/vue-input-components.cjs.js +1 -1
- package/dist/vue-input-components.css +1 -1
- package/dist/vue-input-components.es.js +478 -588
- package/dist/vue-input-components.umd.js +1 -1
- package/package.json +4 -1
- package/src/components/TextInput.vue +106 -44
- package/src/global.ts +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a-vision-software/vue-input-components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.10",
|
|
4
4
|
"description": "A collection of reusable Vue 3 input components with TypeScript support",
|
|
5
5
|
"author": "A-Vision Software",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"import": "./dist/vue-input-components.es.js",
|
|
38
38
|
"require": "./dist/vue-input-components.cjs.js"
|
|
39
39
|
},
|
|
40
|
+
"./global": {
|
|
41
|
+
"types": "./dist/src/global.d.ts"
|
|
42
|
+
},
|
|
40
43
|
"./dist/*": "./dist/*",
|
|
41
44
|
"./styles.css": "./dist/vue-input-components.css",
|
|
42
45
|
"./styles": "./dist/vue-input-components.css"
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
<div
|
|
3
|
+
class="text-input"
|
|
4
|
+
:class="{
|
|
5
|
+
'text-input--disabled': disabled,
|
|
6
|
+
'text-input--has-error': error,
|
|
7
|
+
'text-input--date': type === 'date',
|
|
8
|
+
[`label-${labelPosition}`]: label,
|
|
9
|
+
[`label-align-${labelAlign}`]: label,
|
|
10
|
+
'text-input--has-icon': icon,
|
|
11
|
+
}"
|
|
12
|
+
:style="[
|
|
13
|
+
{ width: width || '100%' },
|
|
14
|
+
labelStyle,
|
|
15
|
+
{
|
|
16
|
+
'--text-input-color': error ? 'var(--danger-color)' : 'var(--text-primary)',
|
|
17
|
+
'--text-input-hover-color': 'var(--primary-color)',
|
|
18
|
+
'--text-input-active-color': 'var(--primary-color)',
|
|
19
|
+
'--text-input-disabled-color': 'var(--text-disabled)',
|
|
20
|
+
'--text-input-background-color': bgColor || 'var(--input-color, #ffffffaa)',
|
|
21
|
+
'--text-dp-background-color': bgColor || '#ffffff',
|
|
22
|
+
'--text-input-border-radius': '0.5rem',
|
|
23
|
+
'--text-input-padding': '0.5rem',
|
|
24
|
+
'--max-textarea-height': maxHeight || height || '14rem',
|
|
25
|
+
'--textarea-height': height || '5.5rem',
|
|
26
|
+
},
|
|
27
|
+
]"
|
|
28
|
+
>
|
|
24
29
|
<label v-if="label" :for="id" class="label">
|
|
25
30
|
{{ label }}
|
|
26
31
|
</label>
|
|
@@ -28,26 +33,72 @@
|
|
|
28
33
|
<div v-if="icon" class="text-input__icon" @click="focusInput">
|
|
29
34
|
<font-awesome-icon :icon="icon" />
|
|
30
35
|
</div>
|
|
31
|
-
<Datepicker
|
|
32
|
-
|
|
33
|
-
:
|
|
36
|
+
<Datepicker
|
|
37
|
+
v-if="type === 'date'"
|
|
38
|
+
:id="id"
|
|
39
|
+
v-model="dateValue"
|
|
40
|
+
:placeholder="placeholder"
|
|
41
|
+
:disabled="disabled"
|
|
42
|
+
:readonly="readonly"
|
|
43
|
+
:min-date="min"
|
|
44
|
+
:max-date="max"
|
|
45
|
+
:format="dateFormat"
|
|
46
|
+
:enable-time-picker="false"
|
|
47
|
+
:auto-apply="true"
|
|
48
|
+
:close-on-auto-apply="true"
|
|
49
|
+
:clearable="true"
|
|
34
50
|
:input-class-name="['text-input__input', { 'text-input__input--has-icon': icon }]"
|
|
35
|
-
@update:model-value="handleDateChange"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
@update:model-value="handleDateChange"
|
|
52
|
+
@focus="handleFocus"
|
|
53
|
+
@blur="handleBlur"
|
|
54
|
+
/>
|
|
55
|
+
<input
|
|
56
|
+
v-else-if="type !== 'textarea'"
|
|
57
|
+
:id="id"
|
|
58
|
+
:type="type"
|
|
59
|
+
:value="modelValue"
|
|
60
|
+
:placeholder="placeholder"
|
|
61
|
+
:required="required"
|
|
62
|
+
:disabled="disabled"
|
|
63
|
+
:readonly="readonly"
|
|
64
|
+
:maxlength="maxlength"
|
|
65
|
+
class="text-input__input"
|
|
66
|
+
@input="handleInput"
|
|
67
|
+
@focus="handleFocus"
|
|
68
|
+
@blur="handleBlur"
|
|
69
|
+
@keydown="handleKeydown"
|
|
70
|
+
ref="inputRef"
|
|
71
|
+
/>
|
|
72
|
+
<textarea
|
|
73
|
+
v-else
|
|
74
|
+
:id="id"
|
|
75
|
+
:value="modelValue"
|
|
76
|
+
:placeholder="placeholder"
|
|
77
|
+
:required="required"
|
|
78
|
+
:disabled="disabled"
|
|
79
|
+
class="text-input__input"
|
|
80
|
+
@input="handleInput"
|
|
81
|
+
ref="inputRef"
|
|
82
|
+
></textarea>
|
|
83
|
+
<span
|
|
84
|
+
v-if="required && !showSaved && !showChanged && !error"
|
|
85
|
+
class="text-input__status required-indicator"
|
|
86
|
+
>required</span
|
|
87
|
+
>
|
|
43
88
|
<transition name="fade">
|
|
44
|
-
<span v-if="showSaved && !showChanged && !error" class="text-input__status saved-indicator"
|
|
89
|
+
<span v-if="showSaved && !showChanged && !error" class="text-input__status saved-indicator"
|
|
90
|
+
>saved</span
|
|
91
|
+
>
|
|
45
92
|
</transition>
|
|
46
93
|
<transition name="fade">
|
|
47
|
-
<span v-if="showChanged && !error" class="text-input__status changed-indicator"
|
|
94
|
+
<span v-if="showChanged && !error" class="text-input__status changed-indicator"
|
|
95
|
+
>changed</span
|
|
96
|
+
>
|
|
48
97
|
</transition>
|
|
49
98
|
<transition name="fade">
|
|
50
|
-
<span v-if="error" class="text-input__status error-indicator" :data-error="error"
|
|
99
|
+
<span v-if="error" class="text-input__status error-indicator" :data-error="error"
|
|
100
|
+
>error</span
|
|
101
|
+
>
|
|
51
102
|
</transition>
|
|
52
103
|
</div>
|
|
53
104
|
</div>
|
|
@@ -77,7 +128,7 @@ const props = withDefaults(defineProps<TextInputProps>(), {
|
|
|
77
128
|
height: '5.5rem',
|
|
78
129
|
maxHeight: '14rem',
|
|
79
130
|
bgColor: 'var(--input-color, #ffffffee)',
|
|
80
|
-
width:
|
|
131
|
+
width: '100%',
|
|
81
132
|
})
|
|
82
133
|
|
|
83
134
|
const emit = defineEmits<{
|
|
@@ -120,6 +171,7 @@ const formatDateForModel = (date: Date | null): string => {
|
|
|
120
171
|
|
|
121
172
|
const parseDateFromModel = (dateStr: string): Date | null => {
|
|
122
173
|
if (!dateStr) return null
|
|
174
|
+
if (dateStr.includes('T')) dateStr = dateStr.split('T')[0]
|
|
123
175
|
const [year, month, day] = dateStr.split('-').map(Number)
|
|
124
176
|
return new Date(year, month - 1, day)
|
|
125
177
|
}
|
|
@@ -216,11 +268,14 @@ onMounted(() => {
|
|
|
216
268
|
}
|
|
217
269
|
})
|
|
218
270
|
|
|
219
|
-
watch(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
271
|
+
watch(
|
|
272
|
+
() => props.modelValue,
|
|
273
|
+
(newValue) => {
|
|
274
|
+
if (props.type === 'date' && newValue) {
|
|
275
|
+
dateValue.value = parseDateFromModel(newValue)
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
)
|
|
224
279
|
|
|
225
280
|
defineExpose({
|
|
226
281
|
focus: () => inputRef.value?.focus(),
|
|
@@ -280,11 +335,20 @@ defineExpose({
|
|
|
280
335
|
gap: 1rem;
|
|
281
336
|
}
|
|
282
337
|
|
|
338
|
+
.text-input.label-left.text-input--date {
|
|
339
|
+
grid-template-columns: auto 1fr;
|
|
340
|
+
}
|
|
341
|
+
|
|
283
342
|
.text-input.label-left .label {
|
|
284
343
|
padding-top: 0.25rem;
|
|
285
344
|
width: 100%;
|
|
286
345
|
}
|
|
287
346
|
|
|
347
|
+
.text-input.label-left.text-input--date .label {
|
|
348
|
+
width: auto;
|
|
349
|
+
white-space: nowrap;
|
|
350
|
+
}
|
|
351
|
+
|
|
288
352
|
.label {
|
|
289
353
|
font-weight: 500;
|
|
290
354
|
color: var(--text-color);
|
|
@@ -325,8 +389,6 @@ defineExpose({
|
|
|
325
389
|
}
|
|
326
390
|
}
|
|
327
391
|
|
|
328
|
-
.text-input {}
|
|
329
|
-
|
|
330
392
|
.text-input--disabled {
|
|
331
393
|
opacity: 0.6;
|
|
332
394
|
cursor: not-allowed;
|
package/src/global.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type TextInput from './components/TextInput.vue'
|
|
2
|
+
import type FileUpload from './components/FileUpload.vue'
|
|
3
|
+
import type Navigation from './components/Navigation.vue'
|
|
4
|
+
import type Action from './components/Action.vue'
|
|
5
|
+
import type Dropdown from './components/Dropdown.vue'
|
|
6
|
+
import type Checkbox from './components/Checkbox.vue'
|
|
7
|
+
import type List from './components/List.vue'
|
|
8
|
+
import type Modal from './components/Modal.vue'
|
|
9
|
+
|
|
10
|
+
declare module '@vue/runtime-core' {
|
|
11
|
+
export interface GlobalComponents {
|
|
12
|
+
TextInput: typeof TextInput
|
|
13
|
+
FileUpload: typeof FileUpload
|
|
14
|
+
Navigation: typeof Navigation
|
|
15
|
+
Action: typeof Action
|
|
16
|
+
Dropdown: typeof Dropdown
|
|
17
|
+
Checkbox: typeof Checkbox
|
|
18
|
+
List: typeof List
|
|
19
|
+
Modal: typeof Modal
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {}
|