@simsustech/quasar-components 0.4.7 → 0.5.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 +13 -0
- package/dist/{QSubmitButton.vue_vue_type_script_setup_true_lang-77aece37.js → QSubmitButton.vue_vue_type_script_setup_true_lang-DAnZaTMl.js} +3 -2
- package/dist/authentication.js +10 -6
- package/dist/en-US-Duo_j_eL.js +227 -0
- package/dist/flags.js +3 -224
- package/dist/form.js +163 -58
- package/dist/general.js +2 -3
- package/dist/icons.js +1 -1
- package/dist/{nl-fa466587.js → nl-BjtwxTCz.js} +3 -0
- package/dist/style.css +11 -1
- package/dist/types/ui/form/BooleanItem.vue.d.ts +1 -1
- package/dist/types/ui/form/DateInput.vue.d.ts +30 -5
- package/dist/types/ui/form/lang/index.d.ts +6 -0
- package/dist/vite-plugin.js +6 -6
- package/package.json +24 -24
- package/src/ui/authentication/LoginForm.vue +3 -0
- package/src/ui/form/BooleanItem.vue +2 -2
- package/src/ui/form/DateInput.vue +170 -34
- package/src/ui/form/EmailInput.vue +2 -0
- package/src/ui/form/lang/en-US.ts +3 -0
- package/src/ui/form/lang/index.ts +3 -0
- package/src/ui/form/lang/nl.ts +3 -0
- package/tsconfig.build.plugin.json +2 -1
- package/tsconfig.json +1 -1
- package/tsconfig.node.json +1 -1
- package/tsconfig.types.json +1 -1
- /package/dist/{nl-7a870643.js → nl-CBxnt0JS.js} +0 -0
- /package/dist/{nl-38cb2607.js → nl-iCAs4ELa.js} +0 -0
- /package/dist/{nl-f499b5cb.js → nl-vB00g7s2.js} +0 -0
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<q-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
<q-field :model-value="modelValue" bottom-slots :rules="validations">
|
|
3
|
+
<template #control>
|
|
4
|
+
<component
|
|
5
|
+
:is="QInput"
|
|
6
|
+
v-for="part in format.split('-')"
|
|
7
|
+
:key="part"
|
|
8
|
+
borderless
|
|
9
|
+
v-bind="dateProps[part]"
|
|
10
|
+
/>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<template #append>
|
|
13
14
|
<q-icon
|
|
14
15
|
v-if="clearable"
|
|
15
16
|
name="clear"
|
|
16
17
|
class="cursor-pointer"
|
|
17
|
-
@click="
|
|
18
|
+
@click="emit('update:modelValue', null)"
|
|
18
19
|
/>
|
|
19
20
|
<q-icon name="event" class="cursor-pointer">
|
|
21
|
+
<q-tooltip v-if="formattedDate">
|
|
22
|
+
{{ formattedDate }}
|
|
23
|
+
</q-tooltip>
|
|
20
24
|
<q-popup-proxy cover transition-show="scale" transition-hide="scale">
|
|
21
25
|
<q-date
|
|
22
26
|
v-bind="date"
|
|
23
|
-
:model-value="modelValue"
|
|
24
|
-
@update:model-value="
|
|
27
|
+
:model-value="modelValue?.replaceAll('-', '/')"
|
|
28
|
+
@update:model-value="setDate"
|
|
25
29
|
>
|
|
26
30
|
<div class="row items-center justify-end">
|
|
27
31
|
<q-btn
|
|
@@ -35,51 +39,170 @@
|
|
|
35
39
|
</q-popup-proxy>
|
|
36
40
|
</q-icon>
|
|
37
41
|
</template>
|
|
38
|
-
</q-
|
|
42
|
+
</q-field>
|
|
39
43
|
</template>
|
|
40
44
|
|
|
41
45
|
<script setup lang="ts">
|
|
42
|
-
import { ref, watch,
|
|
43
|
-
import {
|
|
44
|
-
|
|
46
|
+
import { ref, watch, toRefs, computed } from 'vue'
|
|
47
|
+
import {
|
|
48
|
+
QDate,
|
|
49
|
+
QDateProps,
|
|
50
|
+
QInput,
|
|
51
|
+
QInputProps,
|
|
52
|
+
QuasarLanguageCodes
|
|
53
|
+
} from 'quasar'
|
|
54
|
+
import { useLang } from './lang'
|
|
45
55
|
|
|
46
56
|
export interface Props {
|
|
47
|
-
modelValue
|
|
57
|
+
modelValue: string | null
|
|
58
|
+
format?: 'YYYY-MM-DD' | 'DD-MM-YYYY' | 'MM-DD-YYYY'
|
|
59
|
+
locale?: QuasarLanguageCodes
|
|
48
60
|
label?: string
|
|
49
61
|
required?: boolean
|
|
50
62
|
clearable?: boolean
|
|
51
63
|
date?: Partial<QDateProps>
|
|
52
64
|
}
|
|
53
|
-
const props = defineProps<Props>()
|
|
65
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
66
|
+
format: 'YYYY-MM-DD',
|
|
67
|
+
locale: 'en-US',
|
|
68
|
+
label: '',
|
|
69
|
+
date: () => ({})
|
|
70
|
+
})
|
|
54
71
|
const emit = defineEmits<{
|
|
55
72
|
(e: 'update:modelValue', val: string | null): void
|
|
56
73
|
}>()
|
|
57
|
-
const attrs = useAttrs()
|
|
74
|
+
// const attrs = useAttrs()
|
|
58
75
|
|
|
59
76
|
const lang = useLang()
|
|
60
77
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
const { modelValue, format, locale } = toRefs(props)
|
|
79
|
+
|
|
80
|
+
const year = ref<number>()
|
|
81
|
+
const month = ref<number>()
|
|
82
|
+
const day = ref<number>()
|
|
83
|
+
|
|
84
|
+
const setYear: InstanceType<typeof QInput>['$props']['onUpdate:modelValue'] = (
|
|
85
|
+
val
|
|
86
|
+
) => {
|
|
87
|
+
const nr = Number(val)
|
|
88
|
+
if (nr && nr > 1e3 && nr < 1e4) year.value = nr
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const setMonth: InstanceType<typeof QInput>['$props']['onUpdate:modelValue'] = (
|
|
92
|
+
val
|
|
93
|
+
) => {
|
|
94
|
+
const nr = Number(val)
|
|
95
|
+
if (nr && nr > 0 && nr < 13) month.value = nr
|
|
96
|
+
else month.value = undefined
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const setDay: InstanceType<typeof QInput>['$props']['onUpdate:modelValue'] = (
|
|
100
|
+
val
|
|
101
|
+
) => {
|
|
102
|
+
const nr = Number(val)
|
|
103
|
+
if (nr && nr > 0 && nr < 32) day.value = nr
|
|
104
|
+
else day.value = undefined
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const setInternalDate = (
|
|
108
|
+
dateString?: string | null,
|
|
109
|
+
separator: '-' | '/' = '-'
|
|
110
|
+
) => {
|
|
111
|
+
if (dateString) {
|
|
112
|
+
const [yearPart, monthPart, dayPart] = dateString.split(separator)
|
|
113
|
+
if (yearPart && monthPart && dayPart) {
|
|
114
|
+
year.value = Number(yearPart)
|
|
115
|
+
month.value = Number(monthPart)
|
|
116
|
+
day.value = Number(dayPart)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const setDate: InstanceType<typeof QDate>['$props']['onUpdate:modelValue'] = (
|
|
122
|
+
value
|
|
123
|
+
) => {
|
|
124
|
+
setInternalDate(value, '/')
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
watch([year, month, day], () => {
|
|
128
|
+
const date = `${year.value}-${String(month.value).padStart(2, '0')}-${String(day.value).padStart(2, '0')}`
|
|
129
|
+
if (Date.parse(date)) {
|
|
130
|
+
emit('update:modelValue', date)
|
|
131
|
+
} else {
|
|
132
|
+
emit('update:modelValue', '')
|
|
133
|
+
}
|
|
65
134
|
})
|
|
66
135
|
|
|
67
|
-
const
|
|
136
|
+
const formattedDate = computed(() => {
|
|
137
|
+
if (modelValue.value)
|
|
138
|
+
return new Date(Date.parse(modelValue.value)).toLocaleDateString(
|
|
139
|
+
locale.value,
|
|
140
|
+
{
|
|
141
|
+
weekday: 'long',
|
|
142
|
+
year: 'numeric',
|
|
143
|
+
month: 'short',
|
|
144
|
+
day: 'numeric'
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
return ''
|
|
148
|
+
})
|
|
68
149
|
|
|
69
|
-
|
|
70
|
-
if (
|
|
150
|
+
watch(modelValue, (newVal) => {
|
|
151
|
+
if (newVal) setInternalDate(newVal)
|
|
152
|
+
else if (newVal === null) {
|
|
153
|
+
year.value = undefined
|
|
154
|
+
month.value = undefined
|
|
155
|
+
day.value = undefined
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
setInternalDate(modelValue.value)
|
|
159
|
+
|
|
160
|
+
const goToNextElement = (e: KeyboardEvent) => {
|
|
161
|
+
if (['Minus', 'Slash'].includes(e.code)) {
|
|
162
|
+
e.preventDefault()
|
|
163
|
+
const next = (e.currentTarget as HTMLElement).parentElement?.parentElement
|
|
164
|
+
?.parentElement?.parentElement?.nextElementSibling
|
|
165
|
+
if (next) {
|
|
166
|
+
;(next as HTMLElement).focus()
|
|
167
|
+
}
|
|
168
|
+
}
|
|
71
169
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
170
|
+
|
|
171
|
+
const dateProps = computed<Record<string, QInputProps>>(() => ({
|
|
172
|
+
YYYY: {
|
|
173
|
+
modelValue: year.value,
|
|
174
|
+
placeholder: lang.value.datePicker.YYYY,
|
|
175
|
+
style: 'max-width: 6ch',
|
|
176
|
+
suffix: format.value === 'YYYY-MM-DD' ? '-' : undefined,
|
|
177
|
+
class: format.value !== 'YYYY-MM-DD' ? 'q-mb-none q-ml-xs' : undefined,
|
|
178
|
+
'onUpdate:modelValue': setYear,
|
|
179
|
+
onKeydown: goToNextElement
|
|
180
|
+
},
|
|
181
|
+
MM: {
|
|
182
|
+
modelValue: month.value ? String(month.value).padStart(2, '0') : '',
|
|
183
|
+
placeholder: lang.value.datePicker.MM,
|
|
184
|
+
style: 'max-width: 4ch',
|
|
185
|
+
suffix: '-',
|
|
186
|
+
class: 'q-ml-xs',
|
|
187
|
+
'onUpdate:modelValue': setMonth,
|
|
188
|
+
onKeydown: goToNextElement
|
|
189
|
+
},
|
|
190
|
+
DD: {
|
|
191
|
+
modelValue: day.value ? String(day.value).padStart(2, '0') : '',
|
|
192
|
+
placeholder: lang.value.datePicker.DD,
|
|
193
|
+
style: 'max-width: 4ch',
|
|
194
|
+
suffix: format.value === 'DD-MM-YYYY' ? '-' : undefined,
|
|
195
|
+
class: format.value === 'YYYY-MM-DD' ? 'q-ml-xs' : undefined,
|
|
196
|
+
'onUpdate:modelValue': setDay,
|
|
197
|
+
onKeydown: goToNextElement
|
|
76
198
|
}
|
|
77
|
-
)
|
|
199
|
+
}))
|
|
78
200
|
|
|
79
201
|
const validations = ref<((val: string) => boolean | string)[]>([
|
|
80
202
|
(v) => {
|
|
81
203
|
if (v !== null)
|
|
82
|
-
return /^\d{4}\/(0?[1-9]|1[012])\/(0?[1-9]|[12][0-9]|3[01])$/.test(v)
|
|
204
|
+
// return /^\d{4}\/(0?[1-9]|1[012])\/(0?[1-9]|[12][0-9]|3[01])$/.test(v)
|
|
205
|
+
return /^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/.test(v)
|
|
83
206
|
return true
|
|
84
207
|
}
|
|
85
208
|
])
|
|
@@ -89,3 +212,16 @@ if (props.required)
|
|
|
89
212
|
(val: string) => !!val || lang.value.validations.fieldRequired
|
|
90
213
|
)
|
|
91
214
|
</script>
|
|
215
|
+
|
|
216
|
+
<style>
|
|
217
|
+
.q-field--auto-height .q-field__control,
|
|
218
|
+
.q-field--auto-height .q-field__native {
|
|
219
|
+
min-height: 1em;
|
|
220
|
+
}
|
|
221
|
+
.q-field--borderless .q-field__bottom,
|
|
222
|
+
.q-field--borderless.q-field--dense .q-field__control,
|
|
223
|
+
.q-field--standard .q-field__bottom,
|
|
224
|
+
.q-field--standard.q-field--dense .q-field__control {
|
|
225
|
+
padding-top: 0;
|
|
226
|
+
}
|
|
227
|
+
</style>
|
package/src/ui/form/lang/nl.ts
CHANGED
package/tsconfig.json
CHANGED
package/tsconfig.node.json
CHANGED
package/tsconfig.types.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|